on bbbd6ee help sign in
elk/compiler/Types/Hints.hs
21 lines 724 B history raw
1module Types.Hints (hints) where
3import Control.Arrow (first)
4import qualified Data.Map as Map
5import Guid
6import Libraries
7import Parse.Library (iParse)
8import Parse.Types
9import Types.Substitutions
10import Types.Types
12hints :: GuidCounter [(String, Scheme)]
13hints = mapM toScheme values
14 where
15 addPrefixes = concatMap (\(m,vs) -> map (first (\n -> m ++ "." ++ n)) vs)
16 values = addPrefixes (Map.toList (Map.map Map.toList libraries))
17 toScheme (name, tipeString) =
18 case iParse (fmap toType typeExpr) "libraries" tipeString of
19 Left err -> error (show err)
20 Right tipe -> do scheme <- generalize [] (Forall [] [] tipe)
21 return (name, scheme)