elm/compiler/Types/Hints.hs

21 lines
741 B
Haskell
Raw Normal View History

module Types.Hints (hints) where
2012-04-19 06:32:10 +00:00
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
2012-04-19 06:32:10 +00:00
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) "parsing types in docs.json" tipeString of
Left err -> error (show err)
Right tipe -> do scheme <- generalize [] (Forall [] [] tipe)
return (name, scheme)