1module Compile (compile) where
3import qualified Data.Map as Map
5import qualified AST.Module as Module
6import qualified Canonicalize
8import qualified Nitpick.TopLevelTypes as Nitpick
9import qualified Parse.Helpers as Parse
10import qualified Parse.Parse as Parse
11import qualified Reporting.Error as Error
12import qualified Reporting.Result as Result
13import qualified Reporting.Warning as Warning
14import qualified Type.Inference as TI
23 -> Result.Result Warning.Warning Error.Error Module.CanonicalModule
25compile user projectName isRoot interfaces source =
27 -- determine if default imports should be added
28 -- only elm-lang/core is exempt
30 not (user == "elm-lang" && projectName == "core")
32 -- Parse the source code
34 Result.mapError Error.Syntax $
35 Parse.program needsDefaults isRoot (getOpTable interfaces) source
37 -- Canonicalize all variables, pinning down where they came from.
39 Canonicalize.module' interfaces validModule
41 -- Run type inference on the program.
43 Result.from Error.Type $
44 TI.infer interfaces canonicalModule
46 -- One last round of checks
47 Result.mapError Error.Type $
48 Nitpick.topLevelTypes types (Module.body validModule)
50 -- Add the real list of types
51 let body = (Module.body canonicalModule) { Module.types = types }
53 return $ canonicalModule { Module.body = body }
56getOpTable :: Module.Interfaces -> Parse.OpTable
57getOpTable interfaces =
59 |> concatMap Module.iFixities
60 |> 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