4 , AdtInfo, CanonicalAdt
5 , SourceModule, ValidModule, CanonicalModule
6 , Module(..), CanonicalBody(..)
8 , Name, nameToString, nameIsNative
9 , Interface(..), toInterface
14import qualified Data.List as List
15import qualified Data.Map as Map
16import Control.Applicative ((<$>),(<*>))
18import qualified AST.Expression.Canonical as Canonical
19import qualified AST.Declaration as Decl
20import qualified AST.Type as Type
21import qualified AST.Variable as Var
23import qualified Elm.Compiler.Version as Compiler
24import Text.PrettyPrint as P
27-- HELPFUL TYPE ALIASES
29type Interfaces = Map.Map Name Interface
31type Types = Map.Map String Type.CanonicalType
32type Aliases = Map.Map String ([String], Type.CanonicalType)
33type ADTs = Map.Map String (AdtInfo String)
35type AdtInfo v = ( [String], [(v, [Type.CanonicalType])] )
36type CanonicalAdt = (Var.Canonical, AdtInfo Var.Canonical)
42 Module (Var.Listing Var.Value) [Decl.SourceDecl]
45 Module (Var.Listing Var.Value) [Decl.ValidDecl]
48 Module [Var.Value] CanonicalBody
51data Module exports body = Module
55 , imports :: [(Name, ImportMethod)]
59data CanonicalBody = CanonicalBody
60 { program :: Canonical.Expr
62 , fixities :: [(Decl.Assoc, Int, String)]
71{-| Basic info needed to identify modules and determine dependencies. -}
72data HeaderAndImports = HeaderAndImports
74 , _exports :: Var.Listing Var.Value
75 , _imports :: [(Name, ImportMethod)]
79type Name = [String] -- must be non-empty
82nameToString :: Name -> String
87nameIsNative :: Name -> Bool
97{-| Key facts about a module, used when reading info from .elmi files. -}
98data Interface = Interface
100 , iExports :: [Var.Value]
102 , iImports :: [(Name, ImportMethod)]
104 , iAliases :: Aliases
105 , iFixities :: [(Decl.Assoc, Int, String)]
109toInterface :: CanonicalModule -> Interface
111 let body' = body modul in
113 { iVersion = Compiler.version
114 , iExports = exports modul
115 , iTypes = types body'
116 , iImports = imports modul
117 , iAdts = datatypes body'
118 , iAliases = aliases body'
119 , iFixities = fixities body'
120 , iPorts = ports body'
123instance Binary Interface where
124 get = Interface <$> get <*> get <*> get <*> get <*> get <*> get <*> get <*> get
132 put (iFixities modul)
138data ImportMethod = ImportMethod
139 { alias :: Maybe String
140 , exposedVars :: !(Var.Listing Var.Value)
144instance Binary ImportMethod where
145 put (ImportMethod alias exposedVars) =
150 ImportMethod <$> get <*> get
155instance (Pretty exs, Pretty body) => Pretty (Module exs body) where
156 pretty (Module names _ exs ims body) =
157 P.vcat [modul, P.text "", prettyImports, P.text "", pretty body]
160 P.text "module" <+> name <+> pretty exs <+> P.text "where"
163 P.text (nameToString names)
166 P.vcat $ map prettyMethod ims
169prettyMethod :: (Name, ImportMethod) -> Doc
170prettyMethod (name, ImportMethod maybeAlias exposedVars) =
175 P.text "as" <+> P.text alias
177 prettyAlias <+> pretty exposedVars
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list