Ordinarily, you can only check two values for equality if the type-checker knows that they are the same type.
This module provides an
eqAny function which loosens that restriction. It
works with any two values, so long as each has an
instance. To do so, it checks whether the two
Eq instances are implemented
with the same function. If so, clearly that function can take both values,
and can be called to determine equality. If not, clearly the values are unequal.
Note that it turns out that this mechanism currently works only with
* -> * or higher kinds (see examples below). I am working on a
fix, likely by requiring a
But why would the type-checker not know that the two values are of the same
type? On occasion, it is convenient to "forget" the type of a value, and only
remember some fact about the type -- say, that it has an
This is a little like what
does, except that
Data.Exists doesn't remember anything at all about the
So, this module provides a
someEq function, which turns any value with an
Eq instance into a
SomeEq (with no type variable). All you can do with a
SomeEq is check it for equality with another
SomeEq. The nice thing is
that the two
SomeEq values may originally have been different types.
bower install purescript-exists-eq
Try something like:
git clone https://github.com/rgrempel/purescript-exists-eq bower install pulp test
Documentation for the API can be found on Pursuit. Or, if you are already looking at Pursuit, then below ...