1module Compile (compile) where
3import qualified Data.Map as Map
4import Text.PrettyPrint (Doc)
6import qualified AST.Module as Module
7import qualified Parse.Helpers as Parse
8import qualified Parse.Parse as Parse
9import qualified Transform.AddDefaultImports as DefaultImports
10import qualified Transform.Check as Check
11import qualified Type.Inference as TI
12import qualified Transform.Canonicalize as Canonical
13import Elm.Utils ((|>))
21 -> Either [Doc] Module.CanonicalModule
23compile user projectName interfaces source =
25 -- Parse the source code
27 Parse.program (getOpTable interfaces) source
29 -- determine if default imports should be added
30 -- only elm-lang/core is exempt
32 not (user == "elm-lang" && projectName == "core")
34 -- add default imports if necessary
36 DefaultImports.add needsDefaults parsedModule
38 -- validate module (e.g. all variables exist)
39 case Check.mistakes (Module.body rawModule) of
43 -- Canonicalize all variables, pinning down where they came from.
44 canonicalModule <- Canonical.module' interfaces rawModule
46 -- Run type inference on the program.
47 types <- TI.infer interfaces canonicalModule
49 -- Add the real list of tyes
50 let body = (Module.body canonicalModule) { Module.types = types }
52 return $ canonicalModule { Module.body = body }
55getOpTable :: Module.Interfaces -> Parse.OpTable
56getOpTable interfaces =
58 |> concatMap Module.iFixities
59 |> map (\(assoc,lvl,op) -> (op,(lvl,assoc)))
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