[Haskell-cafe] Instance deriving for Void types.

Andres Löh andres at well-typed.com
Tue Oct 29 11:59:54 UTC 2013


On Tue, Oct 29, 2013 at 5:15 AM, Lyndon Maydwell <maydwell at gmail.com> wrote:

> I was wondering if it's possible to have automatic deriving for some classes
> for the Void type. This would be classes that require a parameter of the
> type in its functions. This should obviously be trivial as the definition
> can be undefined since there's no way to supply a value of the type.
> I guess the obvious one would be Show.
> data Nada deriving Show
> {*
> instance Show Nada where
>   show _ = undefined
> *}

This actually works with StandaloneDeriving:

{-# LANGUAGE StandaloneDeriving #-}

data Nada
deriving instance Show Nada
deriving instance Eq Nada
deriving instance Ord Nada

And I agree, all of these are useful, in particular if Nada is used as
an argument to a parameterized datatype. Trying to derive Read
triggers a compiler bug with 7.6.3, but this seems to be fixed in


Andres Löh, Haskell Consultant
Well-Typed LLP, http://www.well-typed.com

More information about the Haskell-Cafe mailing list