@@ -487,15 +487,12 @@ inferBinder val (NamedBinder name binder) = do
487 return $ M.insert name val m
487 return $ M.insert name val m
488inferBinder val (PositionedBinder pos _ binder) =
488inferBinder val (PositionedBinder pos _ binder) =
489 warnAndRethrowWithPositionTC pos $ inferBinder val binder
489 warnAndRethrowWithPositionTC pos $ inferBinder val binder
490−-- TODO: When adding support for polymorphic types, check subsumption here,
491−-- change the definition of `binderRequiresMonotype`,
492−-- and use `kindOfWithScopedVars`.
493inferBinder val (TypedBinder ty binder) = do
490inferBinder val (TypedBinder ty binder) = do
494 kind <- kindOf ty
491 kind <- kindOf ty
495 checkTypeKind ty kind
492 checkTypeKind ty kind
496− ty1 <- replaceAllTypeSynonyms <=< replaceTypeWildcards $ ty
493+ ty1 <- introduceSkolemScope <=< replaceAllTypeSynonyms <=< replaceTypeWildcards $ ty
497 unifyTypes val ty1
494 unifyTypes val ty1
498− inferBinder val binder
495+ inferBinder ty1 binder
499inferBinder _ OpBinder{} =
496inferBinder _ OpBinder{} =
500 internalError "OpBinder should have been desugared before inferBinder"
497 internalError "OpBinder should have been desugared before inferBinder"
501inferBinder _ BinaryNoParensBinder{} =
498inferBinder _ BinaryNoParensBinder{} =
@@ -510,6 +507,7 @@ binderRequiresMonotype NullBinder = False
510binderRequiresMonotype (VarBinder _) = False
507binderRequiresMonotype (VarBinder _) = False
511binderRequiresMonotype (NamedBinder _ b) = binderRequiresMonotype b
508binderRequiresMonotype (NamedBinder _ b) = binderRequiresMonotype b
512binderRequiresMonotype (PositionedBinder _ _ b) = binderRequiresMonotype b
509binderRequiresMonotype (PositionedBinder _ _ b) = binderRequiresMonotype b
510+binderRequiresMonotype (TypedBinder ty b) = isMonoType ty || binderRequiresMonotype b
513binderRequiresMonotype _ = True
511binderRequiresMonotype _ = True
515-- | Instantiate polytypes only when necessitated by a binder.
513-- | Instantiate polytypes only when necessitated by a binder.