on c2fc03c help sign in
elk/compiler/Types/Hints.hs
24 lines 704 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
16 values = addPrefixes (Map.toList (Map.map Map.toList libraries))
18 addPrefixes = concatMap (\(m,vs) -> map (first (\n -> m ++ "." ++ n)) vs)
20 toScheme (name, tipeString) =
21 case iParse (fmap toType typeExpr) "parsing types in docs.json" tipeString of
22 Left err -> error (show err)
23 Right tipe -> do scheme <- generalize [] =<< superize name tipe
24 return (name, scheme)