on b5b87f2 help sign in
elk/elm/src/Initialize.hs
23 lines 667 B history raw
1module Initialize (initialize) where
3import Control.Applicative ((<$>))
4import Control.Monad.Error
5import Data.List (lookup)
7import Ast
8import Parser (parseProgram)
9import Rename
10import Types ((-:))
11import Types.Hints (hints)
12import Types.Unify
13import Optimize
16initialize str =
17 let nameOf (Definition n _ _) = n in
18 do modul@(Module name ex im stmts) <- parseProgram str
19 (escapees, subs) <- unify hints modul
20 let modul' = optimize . rename $ Module name ex im' stmts
21 where im' | any ((=="Prelude") . fst) im = im
22 | otherwise = ("Prelude", Importing []) : im
23 subs `seq` return (escapees, modul')