@@ -18,6 +18,8 @@ module Language.PureScript.TypeChecker.Types (
1818 typeOf
1919) where
2020
21+import Debug.Trace
22+
2123import Data.List
2224import Data.Maybe (fromMaybe)
2325import Data.Function
@@ -361,7 +363,7 @@ infer m v@(Constructor c) = do
361363 modulePath <- checkModulePath `fmap` lift get
362364 case M.lookup (qualify modulePath c) (dataConstructors env) of
363365 Nothing -> throwError $ "Constructor " ++ show c ++ " is undefined"
364− Just ty -> return ty
366+ Just ty -> lift $ replaceAllTypeSynonyms ty
365367infer m (Case val binders) = do
366368 t1 <- infer m val
367369 ret <- fresh
@@ -377,7 +379,7 @@ infer m v@(TypedValue val ty) = do
377379 kind <- lift $ kindOf ty
378380 guardWith ("Expected type of kind *, was " ++ prettyPrintKind kind) $ kind == Star
379381 ty' <- lift $ replaceAllTypeSynonyms ty
380− check m val ty'
382+ trace (prettyPrintType ty') $ check m val ty'
381383 return ty'
382384
383385inferUnary :: UnaryOperator -> Type -> Subst Check Type
@@ -619,7 +621,9 @@ check m v@(Var var@(Qualified mp name)) ty = do
619621 case mp of
620622 ModulePath [] ->
621623 case M.lookup name m of
622− Just ty1 -> ty1 `subsumes` ty
624+ Just ty1 -> do
625+ repl <- lift $ replaceAllTypeSynonyms ty1
626+ repl `subsumes` ty
623627 Nothing -> lookupGlobal
624628 _ -> lookupGlobal
625629 where
@@ -628,7 +632,9 @@ check m v@(Var var@(Qualified mp name)) ty = do
628632 modulePath <- checkModulePath `fmap` lift get
629633 case M.lookup (qualify modulePath var) (names env) of
630634 Nothing -> throwError $ show var ++ " is undefined"
631− Just (ty1, _) -> ty1 `subsumes` ty
635+ Just (ty1, _) -> do
636+ repl <- lift $ replaceAllTypeSynonyms ty1
637+ repl `subsumes` ty
632638check m val u@(TUnknown _) = do
633639 ty <- infer m val
634640 ty ~~ u
@@ -663,7 +669,9 @@ check m (Constructor c) ty = do
663669 modulePath <- checkModulePath `fmap` lift get
664670 case M.lookup (qualify modulePath c) (dataConstructors env) of
665671 Nothing -> throwError $ "Constructor " ++ show c ++ " is undefined"
666− Just ty1 -> ty1 `subsumes` ty
672+ Just ty1 -> do
673+ repl <- lift $ replaceAllTypeSynonyms ty1
674+ repl `subsumes` ty
667675check m val (SaturatedTypeSynonym name args) = do
668676 env <- lift getEnv
669677 modulePath <- checkModulePath `fmap` lift get