@@ -1,24 +1,22 @@
1module AST.Module
1module AST.Module
2− ( Interfaces, CanonicalInterfaces
2+ ( Interfaces
3 , Types, Aliases, ADTs
3 , Types, Aliases, ADTs
4 , AdtInfo, CanonicalAdt
4 , AdtInfo, CanonicalAdt
5 , SourceModule, ValidModule, CanonicalModule, Optimized
5 , SourceModule, ValidModule, CanonicalModule, Optimized
6 , Module(..), Body(..)
6 , Module(..), Body(..)
7 , Header(..)
7 , Header(..)
8− , Name, nameToString, nameIsNative
9− , CanonicalName(..), canonPkg, canonModul
10 , Interface(..), toInterface
8 , Interface(..), toInterface
11 , UserImport, DefaultImport, ImportMethod(..)
9 , UserImport, DefaultImport, ImportMethod(..)
14import Control.Applicative ((<$>),(<*>))
12import Control.Applicative ((<$>),(<*>))
15import Data.Binary
13import Data.Binary
16−import qualified Data.List as List
17import qualified Data.Map as Map
14import qualified Data.Map as Map
19import qualified AST.Declaration as Decl
16import qualified AST.Declaration as Decl
20import qualified AST.Expression.Canonical as Canonical
17import qualified AST.Expression.Canonical as Canonical
21import qualified AST.Expression.Optimized as Optimized
18import qualified AST.Expression.Optimized as Optimized
19+import qualified AST.Module.Name as Name
22import qualified AST.Type as Type
20import qualified AST.Type as Type
23import qualified AST.Variable as Var
21import qualified AST.Variable as Var
24import qualified Docs.AST as Docs
22import qualified Docs.AST as Docs
@@ -29,8 +27,7 @@ import qualified Reporting.Annotation as A
30-- HELPFUL TYPE ALIASES
28-- HELPFUL TYPE ALIASES
32−type Interfaces = Map.Map Name Interface
30+type Interfaces = Map.Map Name.Canonical Interface
33−type CanonicalInterfaces = Map.Map CanonicalName Interface
35type Types = Map.Map String Type.Canonical
32type Types = Map.Map String Type.Canonical
36type Aliases = Map.Map String ([String], Type.Canonical)
33type Aliases = Map.Map String ([String], Type.Canonical)
@@ -59,15 +56,15 @@ type ValidModule =
61type CanonicalModule =
58type CanonicalModule =
62− Module Docs.Centralized [Name] [Var.Value] (Body Canonical.Expr)
59+ Module Docs.Centralized [Name.Raw] [Var.Value] (Body Canonical.Expr)
65type Optimized =
62type Optimized =
66− Module Docs.Centralized [Name] [Var.Value] (Body Optimized.Expr)
63+ Module Docs.Centralized [Name.Raw] [Var.Value] (Body Optimized.Expr)
69data Module docs imports exports body = Module
66data Module docs imports exports body = Module
70− { names :: Name
67+ { name :: Name.Canonical
71 , path :: FilePath
68 , path :: FilePath
72 , docs :: A.Located (Maybe docs)
69 , docs :: A.Located (Maybe docs)
73 , exports :: exports
70 , exports :: exports
@@ -90,41 +87,19 @@ data Body expr = Body
91{-| Basic info needed to identify modules and determine dependencies. -}
88{-| Basic info needed to identify modules and determine dependencies. -}
92data Header imports = Header
89data Header imports = Header
93− { _names :: Name
90+ { _name :: Name.Raw
94 , _docs :: A.Located (Maybe String)
91 , _docs :: A.Located (Maybe String)
95 , _exports :: Var.Listing (A.Located Var.Value)
92 , _exports :: Var.Listing (A.Located Var.Value)
96 , _imports :: imports
93 , _imports :: imports
100−type Name = [String] -- must be non-empty
105− { canonPkg :: Package.Name
106− , canonModul :: Name
110−nameToString :: Name -> String
112− List.intercalate "."
115−nameIsNative :: Name -> Bool
118− "Native" : _ -> True
122-- IMPORTs
97-- IMPORTs
124−type UserImport = A.Located (Name, ImportMethod)
99+type UserImport = A.Located (Name.Raw, ImportMethod)
127−type DefaultImport = (Name, ImportMethod)
102+type DefaultImport = (Name.Raw, ImportMethod)
130data ImportMethod = ImportMethod
105data ImportMethod = ImportMethod
@@ -137,15 +112,15 @@ data ImportMethod = ImportMethod
138{-| Key facts about a module, used when reading info from .elmi files. -}
113{-| Key facts about a module, used when reading info from .elmi files. -}
139data Interface = Interface
114data Interface = Interface
140− { iVersion :: String
115+ { iVersion :: Package.Version
116+ , iPackage :: Package.Name
141 , iExports :: [Var.Value]
117 , iExports :: [Var.Value]
142 , iTypes :: Types
118 , iTypes :: Types
143− , iImports :: [Name]
119+ , iImports :: [Name.Raw]
144 , iAdts :: ADTs
120 , iAdts :: ADTs
145 , iAliases :: Aliases
121 , iAliases :: Aliases
146 , iFixities :: [(Decl.Assoc, Int, String)]
122 , iFixities :: [(Decl.Assoc, Int, String)]
147 , iPorts :: [String]
123 , iPorts :: [String]
148− , iPackage :: Package.Name
@@ -153,7 +128,8 @@ toInterface :: Package.Name -> CanonicalModule -> Interface
153toInterface pkgName modul =
128toInterface pkgName modul =
154 let body' = body modul in
129 let body' = body modul in
155 Interface
130 Interface
156− { iVersion = Package.versionToString Compiler.version
131+ { iVersion = Compiler.version
132+ , iPackage = pkgName
157 , iExports = exports modul
133 , iExports = exports modul
158 , iTypes = types body'
134 , iTypes = types body'
159 , iImports = imports modul
135 , iImports = imports modul
@@ -161,7 +137,6 @@ toInterface pkgName modul =
161 , iAliases = aliases body'
137 , iAliases = aliases body'
162 , iFixities = fixities body'
138 , iFixities = fixities body'
163 , iPorts = ports body'
139 , iPorts = ports body'
164− , iPackage = pkgName
@@ -169,6 +144,7 @@ instance Binary Interface where
169 get = Interface <$> get <*> get <*> get <*> get <*> get <*> get <*> get <*> get <*> get
144 get = Interface <$> get <*> get <*> get <*> get <*> get <*> get <*> get <*> get <*> get
170 put modul = do
145 put modul = do
171 put (iVersion modul)
146 put (iVersion modul)
147+ put (iPackage modul)
172 put (iExports modul)
148 put (iExports modul)
173 put (iTypes modul)
149 put (iTypes modul)
174 put (iImports modul)
150 put (iImports modul)
@@ -176,4 +152,3 @@ instance Binary Interface where
176 put (iAliases modul)
152 put (iAliases modul)
177 put (iFixities modul)
153 put (iFixities modul)
178 put (iPorts modul)
154 put (iPorts modul)
179− put (iPackage modul)