My code:
{-# LANGUAGE UnboxedTuples, MagicHash, UnliftedNewtypes #-}
import GHC.Exts (ZeroBitType)
type Unit :: ZeroBitType
type Unit = (# #)
type TwoUnits :: ZeroBitType
newtype TwoUnits = TwoUnits (# Unit, Unit #)
The error:
File.hs:10:29: error: [GHC-83865]
• Couldn't match kind: [GHC.Types.ZeroBitRep, GHC.Types.ZeroBitRep]
with: '[]
Expected kind 'ZeroBitType',
but '(# Unit, Unit #)' has kind 'TYPE
(GHC.Types.TupleRep
[GHC.Types.ZeroBitRep, GHC.Types.ZeroBitRep])'
• In the type '(# Unit, Unit #)'
In the definition of data constructor 'TwoUnits'
In the newtype declaration for 'TwoUnits'
|
10 | newtype TwoUnits = TwoUnits (# Unit, Unit #)
| ^^^^^^^^^^^^^^^^
Failed, no modules loaded.
This makes a lot of sense, but also, it’s a bit annoying.
I have some code where I want to enforce that a type doesn’t exist at run-time, but it doesn’t cover cases like this where it’s a tuple of zero-sized types.
Is there any solution?