@@ -99,7 +99,7 @@ ctorToType env (name, tvars, ctors) =
99get :: Environment -> (Environment -> Map.Map String a) -> String -> a
99get :: Environment -> (Environment -> Map.Map String a) -> String -> a
100get env subDict key = Map.findWithDefault err key (subDict env)
100get env subDict key = Map.findWithDefault err key (subDict env)
102− err = error $ "Could not find type constructor '" ++ key ++ "' while checking types."
102+ err = error $ "\nCould not find type constructor '" ++ key ++ "' while checking types."
105freshDataScheme :: Environment -> String -> IO (Int, [Variable], [Type], Type)
105freshDataScheme :: Environment -> String -> IO (Int, [Variable], [Type], Type)
@@ -146,9 +146,11 @@ instantiator env sourceType = go sourceType
146 Just t -> return $ foldl (<|) t ts'
146 Just t -> return $ foldl (<|) t ts'
147 Nothing ->
147 Nothing ->
148 case Map.lookup name (aliases env) of
148 case Map.lookup name (aliases env) of
149− Nothing -> error $ "Could not find type constructor '" ++ name ++ "' while checking types."
149+ Nothing -> error $ "\nCould not find type constructor '" ++ name ++ "' while checking types."
150 Just (tvars, t) ->
150 Just (tvars, t) ->
151+ let tvarLen = length tvars
151− let msg = "Type alias '" ++ name ++ "' expects " ++ show (length tvars) ++
152+ msg = "\nType alias '" ++ name ++ "' expects " ++ show tvarLen ++
153+ " type argument" ++ (if tvarLen == 1 then "" else "s") ++
152 " but was given " ++ show (length ts')
154 " but was given " ++ show (length ts')
153 in if length ts' /= length tvars then error msg else
155 in if length ts' /= length tvars then error msg else
154 do (dict, aliases) <- State.get
156 do (dict, aliases) <- State.get