sanctuary-js / sanctuary-def

Run-time type system for JavaScript
MIT License
294 stars 23 forks source link

fix error message for unmatched parameterized type variable #250

Closed davidchambers closed 5 years ago

davidchambers commented 5 years ago

Commit message:

Consider the following type error:

def ('!') ({}) ([$.UnaryTypeVariable ('f') ($.String)]) (() => 8) ()

Incorrect error message (before):

Type-variable constraint violation

! :: () -> f String
           ^^^^^^^^
              1

1)  8 :: Number

Since there is no type of which all the above values are members, the type-variable constraint has been violated.

Correct error message (after):

Invalid value

! :: () -> f String
           ^^^^^^^^
              1

1)  8 :: Number

The value at position 1 is not a member of ‘f String’.

:warning: The fix requires changing predicates from Any -> Boolean to Array Type -> Any -> Boolean.