Seeing as the type of Void
is uninhabited, can it be regarded as a type \"constructor\"? Or is this just a quick \"hack\" to be able to safely disregard / disable f
Luis Casillas showed that a polymorphic type can be uninhabited in vanilla Haskell. But there are also uninhabited monomorphic types. The classic one looks like this:
data Void = Void !Void
absurd :: Void -> a
absurd (Void x) = absurd x
Imagine trying to construct something of type Void
.
void :: Void
void = Void _
You need something of type Void
to fill the hole. Since that's the whole point of void
, the only sensible choice is
void :: Void
void = Void void
If the Void
constructor were lazy, that would be a cyclical structure Void (Void (Void ...))
. But since it's strict, void
can be written equivalently as
void = void `seq` Void void
which is obviously not going to fly.