@@ -1,6 +1,8 @@
1module Types.Hints (hints) where
1module Types.Hints (hints) where
3import Control.Arrow (first)
3import Control.Arrow (first)
4+import Control.Monad (liftM)
5+import Data.Maybe (catMaybes)
4import qualified Data.Map as Map
6import qualified Data.Map as Map
6import qualified Libraries as Libs
8import qualified Libraries as Libs
@@ -10,7 +12,7 @@ import qualified Types.Substitutions as Subs
10import Types.Types
12import Types.Types
12hints :: GuidCounter [(String, Scheme)]
14hints :: GuidCounter [(String, Scheme)]
13−hints = mapM toScheme values
15+hints = liftM catMaybes (mapM toScheme values)
15 values :: [(String, String)]
17 values :: [(String, String)]
16 values = addPrefixes (Map.toList (Map.map Map.toList Libs.libraries))
18 values = addPrefixes (Map.toList (Map.map Map.toList Libs.libraries))
@@ -18,10 +20,12 @@ hints = mapM toScheme values
18 addPrefixes :: [(String,[(String, String)])] -> [(String, String)]
20 addPrefixes :: [(String,[(String, String)])] -> [(String, String)]
19 addPrefixes = concatMap (\(m,vs) -> map (first (\n -> m ++ "." ++ n)) vs)
21 addPrefixes = concatMap (\(m,vs) -> map (first (\n -> m ++ "." ++ n)) vs)
21− toScheme :: (String, String) -> GuidCounter (String, Scheme)
23+ toScheme :: (String, String) -> GuidCounter (Maybe (String, Scheme))
24+ toScheme (name, 't':'y':'p':'e':' ':_) = return Nothing
25+ toScheme (name, 'd':'a':'t':'a':' ':_) = return Nothing
22 toScheme (name, tipeString) =
26 toScheme (name, tipeString) =
23− let err = "in docs.json parsing type: " ++ tipeString in
27+ let err = "compiler error parsing type of " ++ name ++ ":\n" ++ tipeString in
24 case iParse (fmap toType typeExpr) err tipeString of
28 case iParse (fmap toType typeExpr) err tipeString of
25 Left err -> error (show err)
29 Left err -> error (show err)
26 Right tipe -> do scheme <- Subs.generalize [] =<< Subs.superize name tipe
30 Right tipe -> do scheme <- Subs.generalize [] =<< Subs.superize name tipe
27− return (name, scheme)
31+ return (Just (name, scheme))