Have you ever been frustrated by having to add extra type information when using coerce
or unsafeCoerce
? Have you ever wanted to simply tell the compiler, ‘Just turn the Foo
s into Bar
s,’ without having to resort to coerce @([(a, Foo)] -> f b) @([(a, Bar)] -> f b)
or coerceFooBar :: ([(a, Foo)] -> f b) -> [(a, Bar)] -> f b
or similar to avoid complaints about how a
can’t possibly be unified with a0
?
If so, my new library coerce-with-substitution
is for you.
With only two lines of value-level code[1], and no dependencies other than base
, it is one of the lightest dependencies you could ever imagine adding to your project. It is also, I hope, one of the best documented. Even the unpublished source comments should be an informative and perhaps mildly entertaining read.
This is a candidate release; I’m very interested in the sort of feedback that would be difficult to incorporate after a formal release. Is something named poorly? Does some behavior surprise you? Is the documentation too verbose, missing any important details, or insufficiently Diátactic? I will probably hold off on making a permanent release until late July, so please let me know what you think I should change to make this the little library you’d want to use!
They are
coerceSubst = coerce
andunsafeCoerceSubst = unsafeCoerce
, and of course they’re markedINLINE
. ↩︎