Currently, the InvalidDecoder type doesn't have an Eq instance. Hence, the result of extract auto expr, which has type Extractor Src Void a == Validation (ExtractErrors Src Void) == Validation (DhallErrors (ExtractError Src Void)), doesn't have an Eq instance (even though Validation has one for (Eq e, Eq a) => Eq (Validation e a) and DhallErrors for Eq e => Eq (DhallErrors e)).
ExtractError is defined as
data ExtractError s a =
TypeMismatch (InvalidDecoder s a)
| ExpectedTypeError ExpectedTypeError
| ExtractError Text
where ExpectedTypeError and Text have their proper Eq instance, but InvalidDecoder s a doesn't. This seems to be a pair of Expr s as which has an Eq instance: (Eq s, Eq a) => Eq (Expr s a).
In my case, s is Src and a is Void, which both have Eq instances.
Hence, is there a reason not to derive an Eq for InvalidDecoder s a (and then for ExtractError as well)?
The reason I'm asking: I'm using Hedgehog's tripping property test to ensure ToDhall and FromDhall instances obey (basically) \v -> let e = embed inject v in pure e == extract auto e. Given how tripping is defined (tripping :: (MonadTest m, Applicative f, Show b, Show (f a), Eq (f a), HasCallStack) => a -> (a -> b) -> (b -> f a) -> m ()), I need to throw out the errors (since there's no Eq instance for f a) by taking the result of extract auto b, turning it into Maybe a, discarding any potential errors (which would otherwise end up in Hedgehog's error message).
Currently, the
InvalidDecoder
type doesn't have anEq
instance. Hence, the result ofextract auto expr
, which has typeExtractor Src Void a
==Validation (ExtractErrors Src Void)
==Validation (DhallErrors (ExtractError Src Void))
, doesn't have anEq
instance (even thoughValidation
has one for(Eq e, Eq a) => Eq (Validation e a)
andDhallErrors
forEq e => Eq (DhallErrors e)
).ExtractError
is defined aswhere
ExpectedTypeError
andText
have their properEq
instance, butInvalidDecoder s a
doesn't. This seems to be a pair ofExpr s a
s which has anEq
instance:(Eq s, Eq a) => Eq (Expr s a)
.In my case,
s
isSrc
anda
isVoid
, which both haveEq
instances.Hence, is there a reason not to derive an
Eq
forInvalidDecoder s a
(and then forExtractError
as well)?The reason I'm asking: I'm using Hedgehog's
tripping
property test to ensureToDhall
andFromDhall
instances obey (basically)\v -> let e = embed inject v in pure e == extract auto e
. Given howtripping
is defined (tripping :: (MonadTest m, Applicative f, Show b, Show (f a), Eq (f a), HasCallStack) => a -> (a -> b) -> (b -> f a) -> m ()
), I need to throw out the errors (since there's noEq
instance forf a
) by taking the result ofextract auto b
, turning it intoMaybe a
, discarding any potential errors (which would otherwise end up in Hedgehog's error message).