The void package claims to provide an uninhabitable type called Void, which is defined as follows –
newtype Void = Void Void
How is this definition any better than using something simpler? Say –
data Void
If my understanding is correct, both the data types contain only bottom values. However the latter is much easier to understand.
EDIT: Okay so I understand Daniel’s answer below. However I thought of another possibly simpler way to do this while remaining Haskell98 compatible. We can use an Abstract data type and expose no constructors to the user.
module Data.Void (Void) where
data Void = Void
Now only code in Data.Void module can construct a Void, however since we know it doesn’t, the Void datatype is effectively uninhabited.
Would that work or am I missing something here?
From description for the void package on Hackage: “A Haskell 98 logically uninhabited data type” (my emphasis). Declaring
Voidas simplydata Voidwould require either Haskell 2010 or the “EmptyDataDecls” language extension and thus would not be “Haskell 98”.EDIT
Here is a page on the Haskell Wiki that describes exactly this situation.