2012-08-09 14:38:18 +00:00
|
|
|
module Types.Hints (hints) where
|
2012-04-19 06:32:10 +00:00
|
|
|
|
2012-05-15 06:12:18 +00:00
|
|
|
import Control.Arrow (first)
|
2013-03-17 05:24:18 +00:00
|
|
|
import qualified Data.Map as Map
|
|
|
|
import Guid
|
|
|
|
import Libraries
|
|
|
|
import Parse.Library (iParse)
|
|
|
|
import Parse.Types
|
|
|
|
import Types.Substitutions
|
2012-11-23 04:30:37 +00:00
|
|
|
import Types.Types
|
2012-04-19 06:32:10 +00:00
|
|
|
|
2013-03-17 05:24:18 +00:00
|
|
|
hints :: GuidCounter [(String, Scheme)]
|
|
|
|
hints = mapM toScheme values
|
2013-04-08 00:55:34 +00:00
|
|
|
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 [] =<< superize name tipe
|
|
|
|
return (name, scheme)
|