[Haskell-cafe] Instance deriving for Void types.
Tom Ellis
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Tue Oct 29 08:18:24 UTC 2013
On Tue, Oct 29, 2013 at 04:31:49AM +0000, AntC wrote:
> > Lyndon Maydwell <maydwell <at> gmail.com> writes:
> >
> > I was wondering if it's possible to have automatic deriving
> > for some classes for the Void type. ...
>
> Hi Lyndon, I'm struggling to see any use case for that.
>
> You'd 'achieve' `show (undefined :: Nada)` crashing your program at run-
> time; rather than failing to compile (if you didn't have the instance).
>
> Just bite the bullet and give your Void type a constructor.
It was considered a worthwhile enough idea to add a Show instance to the
"void" package
http://hackage.haskell.org/package/void-0.6.1/docs/Data-Void.html
(where the instance was written by hand, of course, not derived).
Lyndon: perhaps
import Data.Void
newtype Nada = Nada Void deriving (Show)
will suit you use case.
Tom
More information about the Haskell-Cafe
mailing list