Created
August 25, 2015 22:05
-
-
Save JoeyEremondi/6584566e5746d5d7258e to your computer and use it in GitHub Desktop.
Proposed type changes for adding user/project info to Var.Canonical
This file contains hidden or 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
--In general, we create a new type, Module.FullName, which pairs a Name with its user and project names | |
--This means, in code that just passes through the module name, we just change the type signature to FullName | |
--And it works, until we reach code that actually accesses the name | |
--AST.Module: | |
type Name = [String] -- must be non-empty | |
type FullName = ((String, String), [String]) | |
--AST.Variable: | |
data Home | |
= BuiltIn | |
| Module ((String, String), [String]) | |
| TopLevel ((String, String), [String]) | |
| Local | |
deriving (Eq, Ord, Show) | |
--Canonicalize.Environment | |
--We store the user and project of each import in the environment | |
--There's a new Patch type for adding them during Setup | |
data Environment = Env | |
{ _home :: Module.FullName | |
, _values :: Dict Var.Canonical | |
, _adts :: Dict Var.Canonical | |
, _aliases :: Dict (Var.Canonical, [String], Type.Canonical) | |
, _patterns :: Dict (Var.Canonical, Int) | |
, _pkgInfo :: Map.Map (Module.Name) (Module.FullName) | |
} | |
data Patch | |
= Value String Var.Canonical | |
| Union String Var.Canonical | |
| Alias String (Var.Canonical, [String], Type.Canonical) | |
| Pattern String (Var.Canonical, Int) | |
| FullName [String] (String, String) | |
--Canonicalize | |
--We get passed the current module's user and project from Compile.hs | |
module' | |
:: (String, String) | |
-> Module.Interfaces | |
-> Module.ValidModule | |
-> R.Result Warning.Warning Error.Error Module.CanonicalModule | |
--Canonicalize.Setup.hs | |
--We need the current package's info to initialize our environment | |
environment | |
:: Module.Interfaces | |
-> (String, String) | |
-> Module.ValidModule | |
-> Result.ResultErr Env.Environment | |
declarationsToPatches | |
:: Module.FullName | |
-> [D.ValidDecl] | |
-> ([Node], [Env.Patch]) | |
--The types are unchanged, but here we generate patches for storing | |
--the user/project read from the Interface in our environment | |
interfacePatches :: Module.Name -> String -> Module.Interface -> [Env.Patch] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment