Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.d/fix_4196.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Support solving constraints of values where a polymorphic type was matched.
3 changes: 2 additions & 1 deletion src/Language/PureScript/TypeChecker/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,8 @@ check' v@(Var _ var) ty = do
checkVisibility var
repl <- introduceSkolemScope <=< replaceAllTypeSynonyms <=< lookupVariable $ var
ty' <- introduceSkolemScope <=< replaceAllTypeSynonyms <=< replaceTypeWildcards $ ty
elaborate <- subsumes repl ty'
currentSubst <- gets checkSubstitution
elaborate <- subsumes (substituteType currentSubst repl) ty'
return $ TypedValue' True (elaborate v) ty'
check' (DeferredDictionary className tys) ty = do
{-
Expand Down
17 changes: 9 additions & 8 deletions tests/purs/failing/3765.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,32 @@ at tests/purs/failing/3765.purs:6:23 - 6:24 (line 6, column 23 - line 6, column

Could not match type
 
 ( b :: Int
 ( a :: Int
 ... 
 | t0 
 ) 
 
with type
 
 ( a :: Int
 ( b :: Int
 ... 
 | t0 
 ) 
 

while trying to match type { b :: Int
| t0 
} 
with type t1
while checking that type { a :: Int
| t0 
} 
is at least as general as type { b :: Int
| t0 
} 
while checking that expression x
has type { b :: Int
| t0 
} 
in value declaration mkTricky

where t1 is an unknown type
t0 is an unknown type
where t0 is an unknown type

See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
or to contribute content related to this error.
Expand Down
6 changes: 2 additions & 4 deletions tests/purs/failing/SuggestComposition.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ at tests/purs/failing/SuggestComposition.purs:7:5 - 7:6 (line 7, column 5 - line
while trying to match type { g :: t0
| t1 
} 
with type t2 -> t3
with type Int -> Int
while checking that expression g
has type { g :: t0
| t1 
} 
while checking type of property accessor g.g
in value declaration f

where t2 is an unknown type
t3 is an unknown type
t0 is an unknown type
where t0 is an unknown type
t1 is an unknown type

See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
Expand Down
14 changes: 14 additions & 0 deletions tests/purs/passing/BoundVariableSubsumption.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Main where

import Prelude
import Effect.Console (log)

class Con

newtype Identity a = Identity a

test :: Con => Identity (Con => Int) -> Int
test (Identity a) = a

main = do
log "Done"