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
It's a type of kind *
just like Int
, Bool
or ()
. It just happens to have 0 values instead of 1 or 2 or more.
It's not a hack but rather a fundamental part of Haskell's type system. It plays the role of 0 to ()
's 1 and, if we look at types as propositions, Void
corresponds to the proposition "false". It's also an identity to sum types (Either
) just like ()
is an identity to product types: Either a Void
is isomorphic to a
.
In practice, it often acts as a dual of ()
; the best example of this I've seen is in pipes where ()
is used to tag things that don't take inputs and Void
(named X
) is used to tag things that don't produce outputs. (See Appendix:Types in the tutorial.)
It is a way to mark things as impossible or missing, but it is by no means a hack.