-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Use halogen-store for app shared state
- Loading branch information
Showing
14 changed files
with
175 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module App.Components.AppStore where | ||
|
||
import FatPrelude | ||
import Prim hiding (Row) | ||
|
||
import App.Evaluator.Common (LocalFormulaCtx) | ||
import App.SyntaxTree.Common (Module, QVar, QVarOp, preludeModule) | ||
import App.SyntaxTree.FnDef (FnInfo, OpInfo) | ||
import Data.HashMap as HashMap | ||
import Data.Tree.Zipper (fromTree) | ||
|
||
type Store = | ||
{ fnsMap :: HashMap QVar FnInfo | ||
, operatorsMap :: HashMap QVarOp OpInfo | ||
, aliasedModulesMap :: HashMap (Module /\ Module) (Set Module) | ||
, importedModulesMap :: HashMap Module (Set Module) | ||
} | ||
|
||
type StoreAction = Store -> Store | ||
|
||
initialStore :: Store | ||
initialStore = | ||
{ fnsMap: HashMap.empty | ||
, operatorsMap: HashMap.empty | ||
, aliasedModulesMap: HashMap.empty | ||
, importedModulesMap: HashMap.empty | ||
} | ||
|
||
reduce :: Store -> StoreAction -> Store | ||
reduce store k = k store | ||
|
||
mkLocalContext :: Store -> LocalFormulaCtx | ||
mkLocalContext store = | ||
{ tableData: HashMap.empty | ||
, fnsMap: store.fnsMap | ||
, operatorsMap: store.operatorsMap | ||
, aliasedModulesMap: store.aliasedModulesMap | ||
, importedModulesMap: store.importedModulesMap | ||
, localFnsMap: HashMap.empty | ||
, argsMap: HashMap.empty | ||
, module': preludeModule | ||
, scope: zero | ||
, scopeLoc: fromTree $ mkLeaf zero | ||
, lambdaCount: zero | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.