2module Build.Source (build) where
4import qualified Data.Map as Map
5import Text.PrettyPrint (Doc)
7import qualified AST.Module as Module
8import qualified Parse.Parse as Parse
9import qualified Metadata.Prelude as Prelude
10import qualified Transform.Check as Check
11import qualified Type.Inference as TI
12import qualified Transform.Canonicalize as Canonical
14build :: Bool -> Module.Interfaces -> String -> Either [Doc] Module.CanonicalModule
15build 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 <- Prelude.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