Effect CommunityEC
Effect Community2y ago
33 replies
Kristian Notari

Need for Higher Kinded Types in Composing Refinements

I was looking at composing refinements, but noticed that there's no real way of accomplish the following without HKT right?

const hasPropertyWith: ... = (v, p, refinement) => Predicate.hasProperty(p)(v) && refinement(v[p])
const hasPropertyNotNull = hasPropertyWith(Predicate.isNotNull)


Cause Predicate.isNotNull is (correctly) typed as:
<A>(input: A): input is Exclude<A, null> => input !== null


Which means
A
should be set later on, while it's always set immediately when creating the hasPropertyNotNull refinement. Is it correct?
Was this page helpful?