[Haskell-cafe] Instance deriving for Void types.

AntC anthony_clayden at clear.net.nz
Tue Oct 29 04:31:49 UTC 2013


> 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.

AntC

> 
> I guess the obvious one would be Show.
> 
> data Nada deriving Show
> 
> {*
> instance Show Nada where
>   show _ = undefined
> *}
> 



More information about the Haskell-Cafe mailing list