1module Compile (compile) where
3import qualified Data.Map as Map
4import Text.PrettyPrint (Doc)
6import qualified AST.Module as Module
7import qualified Parse.Parse as Parse
8import qualified Transform.AddDefaultImports as DefaultImports
9import qualified Transform.Check as Check
10import qualified Type.Inference as TI
11import qualified Transform.Canonicalize as Canonical
14compile :: Bool -> Module.Interfaces -> String -> Either [Doc] Module.CanonicalModule
15compile noPrelude interfaces source =
16 do let infixes = Map.fromList . map (\(assoc,lvl,op) -> (op,(lvl,assoc)))
17 . concatMap Module.iFixities $ Map.elems interfaces
19 -- Parse the source code and validate that it is well formed.
21 modul <- DefaultImports.add noPrelude `fmap` Parse.program infixes source
22 case Check.mistakes (Module.body modul) of
26 -- Canonicalize all variables, pinning down where they came from.
27 canonicalModule <- Canonical.module' interfaces validModule
29 -- Run type inference on the program.
30 types <- TI.infer interfaces canonicalModule
32 -- Add the real list of tyes
33 let body = (Module.body canonicalModule) { Module.types = types }
35 return $ canonicalModule { Module.body = body }
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