@@ -50,7 +50,7 @@ addDataConstructor moduleName name args dctor maybeTy = do
5050 let retTy = foldl TypeApp (TypeConstructor (Qualified (Just moduleName) name)) (map TypeVar args)
5151 let dctorTy = maybe retTy (\ty -> Function [ty] retTy) maybeTy
5252 let polyType = mkForAll args dctorTy
53− putEnv $ env { dataConstructors = M.insert (moduleName, dctor) polyType (dataConstructors env) }
53+ putEnv $ env { dataConstructors = M.insert (moduleName, dctor) (polyType, DataConstructor) (dataConstructors env) }
5454
5555addTypeSynonym :: ModuleName -> ProperName -> [String] -> Type -> Kind -> Check ()
5656addTypeSynonym moduleName name args ty kind = do
@@ -183,16 +183,16 @@ typeCheckAll currentModule (ImportDeclaration moduleName idents : rest) = do
183183 Nothing -> throwError (show moduleName ++ "." ++ show pn ++ " is undefined")
184184 Just (k, _) -> do
185185 modifyEnv (\e -> e { types = M.insert (currentModule, pn) (k, DataAlias moduleName pn) (types e) })
186− let keys = map (snd . fst) . filter (\(_, fn) -> fn `constructs` pn) . M.toList . dataConstructors $ env
186+ let keys = map (snd . fst) . filter (\(_, (fn, _)) -> fn `constructs` pn) . M.toList . dataConstructors $ env
187187 forM_ keys $ \dctor -> do
188188 guardWith (show currentModule ++ "." ++ show dctor ++ " is already defined") $ (currentModule, dctor) `M.notMember` dataConstructors env
189189 case (moduleName, dctor) `M.lookup` dataConstructors env of
190− Just ctorTy -> modifyEnv (\e -> e { dataConstructors = M.insert (currentModule, dctor) ctorTy (dataConstructors e) })
190+ Just (ctorTy, _) -> modifyEnv (\e -> e { dataConstructors = M.insert (currentModule, dctor) (ctorTy, Alias moduleName (Ident (runProperName dctor))) (dataConstructors e) })
191191 Nothing -> throwError (show moduleName ++ "." ++ show dctor ++ " is undefined")
192192 constructs (TypeConstructor (Qualified (Just mn) pn')) pn
193193 = mn == moduleName && pn' == pn
194194 constructs (ForAll _ ty) pn = ty `constructs` pn
195195 constructs (Function _ ty) pn = ty `constructs` pn
196196 constructs (TypeApp ty _) pn = ty `constructs` pn
197− constructs fn _ = error $ "Invalid arguments to construct" ++ show fn
197+ constructs fn _ = error $ "Invalid arguments to constructs: " ++ show fn
198198