Closed raehik closed 2 weeks ago
A potential discussion on design:
validate' :: forall {k} ...
is really the preferred external function signature. It would be nicer to switch the names of validate
and validate'
. However, it would break certain custom Predicate
instances. In the first place validate
is a fairly internal function, so I figured there wasn't a good enough reason to switch.
The type ordering is unfortunate. This looks good to me. Having both validate
and validate'
makes me sad, but like you said, it's mostly internal. The docs should definitely mention this issue though.
I clarified the validate'
situation so there should be no confusion.
@chessai any further thoughts on this PR? I'm using it in 2 projects without issue (though it is more of a library concern than user-facing)
This is fairly ready to merge, but I'm loathe to push it forwards as I'd prefer to remove Typeable
constraints from combinator predicates altogether. I've already done this in rerefined. See #101 for an overview of the changes required.
An earlier change #83 enabled using non-
Type
-kinded predicates. To support this,Predicate (p :: k) x
instances were changed to explicitly include aTypeable k
constraint. Every instance that wishes to support non-Type
-kinded predicates (e.g. further predicate operators likeAnd
,Not
) must add this constraint.This PR moves the
Typeable k
constraint to the class definition. (Note thatTypeable p
was already present.) We remove lots of newly spuriousTypeable
constraints. We also fix an oversight in the instances for binary predicate operators, where the kind of predicatesl
andr
were arbitrarily required to be the same kindk
. Thanks to this change, we can remove the explicit kind quantifying and let GHC correctly inferl :: k1
,r :: k2
.Due to GHC's rules on inferring type variable order,
validate
becomes awkward to use with TypeApplications.validate'
provides original behaviour. Potential discussion there.This might break certain custom predicate operator instances, but I'm not sure.