Should `injectReflexive` be the first `Inject` instance?
hdgarrood opened this issue · comments
Harry Garrood commented
See discussion in purescript/documentation#211
With the current instance, we have:
> import Data.Either
> import Data.Either.Inject
> x = Left 0 :: Either Int String
> inj x :: Either Int String
Error found:
in module $PSCI
at <internal> line 0, column 0 - line 0, column 0
No type class instance was found for
Data.Either.Inject.Inject (Either Int String)
String
while applying a function inj
of type Inject t0 t1 => t0 -> t1
to argument x
while checking that expression inj x
has type Either Int String
in value declaration it
where t0 is an unknown type
t1 is an unknown type
See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
or to contribute content related to this error.
If being able to have inj
specialise to the identity function is important, should injectReflexive
go first? Alternatively, should we consider just dropping the instance?
Gary Burgess commented
Yeah, I think the reflexive instance should go first - revisiting the paper that introduced instance chains, that's how they have it defined too.