elm/compiler/Types/Hints.hs
evancz 7dbb052b22 Load json representation of types with Template Haskell, so library files are the base truth of type information.
Make minor fixes in libraries, such as adding the Char labrary and fixing the types in the Dict library.
2013-03-16 22:24:18 -07:00

21 lines
No EOL
724 B
Haskell

module Types.Hints (hints) where
import Control.Arrow (first)
import qualified Data.Map as Map
import Guid
import Libraries
import Parse.Library (iParse)
import Parse.Types
import Types.Substitutions
import Types.Types
hints :: GuidCounter [(String, Scheme)]
hints = mapM toScheme values
where
addPrefixes = concatMap (\(m,vs) -> map (first (\n -> m ++ "." ++ n)) vs)
values = addPrefixes (Map.toList (Map.map Map.toList libraries))
toScheme (name, tipeString) =
case iParse (fmap toType typeExpr) "libraries" tipeString of
Left err -> error (show err)
Right tipe -> do scheme <- generalize [] (Forall [] [] tipe)
return (name, scheme)