Skip to content

Commit a7c71d4

Browse files
committed
Don't monomorphize type constructors
1 parent 0b5a87e commit a7c71d4

File tree

1 file changed

+5
-5
lines changed
  • src/Language/PureScript/TypeChecker

1 file changed

+5
-5
lines changed

src/Language/PureScript/TypeChecker/Types.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import Language.PureScript.Crash
5050
import Language.PureScript.Environment
5151
import Language.PureScript.Errors
5252
import Language.PureScript.Names
53-
import Language.PureScript.Traversals
5453
import Language.PureScript.TypeChecker.Deriving
5554
import Language.PureScript.TypeChecker.Entailment
5655
import Language.PureScript.TypeChecker.Kinds
@@ -374,6 +373,7 @@ infer' (Literal ss (ObjectLiteral ps)) = do
374373
-- They need to be instantiated here.
375374
let shouldInstantiate :: Expr -> Bool
376375
shouldInstantiate Var{} = True
376+
shouldInstantiate Constructor{} = True
377377
shouldInstantiate (PositionedValue _ _ e) = shouldInstantiate e
378378
shouldInstantiate _ = False
379379

@@ -431,8 +431,7 @@ infer' v@(Constructor _ c) = do
431431
env <- getEnv
432432
case M.lookup c (dataConstructors env) of
433433
Nothing -> throwError . errorMessage . UnknownName . fmap DctorName $ c
434-
Just (_, _, ty, _) -> do (v', ty') <- sndM (introduceSkolemScope <=< replaceAllTypeSynonyms) <=< instantiatePolyTypeWithUnknowns v $ ty
435-
return $ TypedValue' True v' ty'
434+
Just (_, _, ty, _) -> TypedValue' True v <$> (introduceSkolemScope <=< replaceAllTypeSynonyms $ ty)
436435
infer' (Case vals binders) = do
437436
(vals', ts) <- instantiateForBinders vals binders
438437
ret <- freshTypeWithKind kindType
@@ -795,7 +794,7 @@ check' v@(Constructor _ c) ty = do
795794
Nothing -> throwError . errorMessage . UnknownName . fmap DctorName $ c
796795
Just (_, _, ty1, _) -> do
797796
repl <- introduceSkolemScope <=< replaceAllTypeSynonyms $ ty1
798-
ty' <- introduceSkolemScope ty
797+
ty' <- introduceSkolemScope <=< replaceAllTypeSynonyms $ ty
799798
elaborate <- subsumes repl ty'
800799
return $ TypedValue' True (elaborate v) ty'
801800
check' (Let w ds val) ty = do
@@ -841,7 +840,8 @@ checkProperties expr ps row lax = convert <$> go ps (toRowPair <$> ts') r' where
841840
go ((p,v):ps') ts r =
842841
case lookup (Label p) ts of
843842
Nothing -> do
844-
v'@(TypedValue' _ _ ty) <- infer v
843+
ty <- freshTypeWithKind kindType
844+
v' <- check v ty
845845
rest <- freshTypeWithKind (kindRow kindType)
846846
unifyTypes r (srcRCons (Label p) ty rest)
847847
ps'' <- go ps' ts rest

0 commit comments

Comments
 (0)