[Haskell] Haskell type containing no non-_|_ values?

Josef Svenningsson josefs at cs.chalmers.se
Fri Mar 26 13:48:49 EST 2004

Hi Janis!

On Fri, 26 Mar 2004, Janis Voigtlaender wrote:

> probably a trivial question: Is there a type in Haskell that contains
> only the undefined value _|_?
> The polymorphic type (forall a. a) has this property, but it seems it
> cannot be used, e.g., in a tuple:
> > x :: (Int,(forall a. a))
> > x = (3,undefined)
> leads to errors both in Hugs and GHC.
> I guess I can help myself out using newtype:
> > newtype T = T (forall a. a)
> > x :: (Int,T)
> > x = (3,undefined)
> but would like to do without. Is there a way?
Yep, there is a way.

newtype Void = Void Void

This type only have the following value:

void = Void void

Now, someone on this mailing list will surely think that this looks
different from undefined. But remember that the constructors in newtype
definitions are only there as a hint for the typechecker, they have no
operational meaning. So void is really undefined.



More information about the Haskell mailing list