Add dual of vacuous
treeowl opened this issue · 3 comments
treeowl commented
There's an obvious
whatever :: Contravariant f => f a -> f Void
whatever = contramap absurd
and I believe this should work as well:
unsafeWhatever :: Contravariant f => f a -> f Void
unsafeWhatever = unsafeCoerce
That way, unsafeVacuous . unsafeWhatever
will turn an f a
into an f b
for free if f
is both a Functor
and Contravariant
.
treeowl commented
If you tell me what to call it and where to put it, I'll make a pull request.
ekmett commented
unsafeVacuous . unsafeWhatever
is now phantom
, provided by this package.
contramap absurd
still doesn't have a name though.
ekmett commented
Given the lack of a good name for it, and the lack of a better than direct definition definition for it, I think that having phantom
should be enough.