unsafeVacuous in Data.Void.Unsafe and .# and #. in Data.Profunctor.Unsafe both warn of the dangers of using these functions with functors / profilers that are GADT. Some dangerous examples are obvious:
data Foo a where P :: a -> Foo a Q :: Foo Void instance Functor Foo where fmap f (P x) = P (fx) fmap f Q = P (f undefined)
Here unsafeVacuous Q will create a Q constructor with a dummy type.
This example is not very worrying, because it does not even look remotely like a reasonable instance of Functor . Are there any examples? In particular, would it be possible to create useful ones that obey the laws of a functor / profuntor when manipulated only using their public API, but break terribly in the face of these unsafe functions?
source share