Skip to content

TypeError requires UndecidableInstances unnecessarily

The example from the TypeError documentation

type family ByteSize x where
    ByteSize Word16   = 2
    ByteSize Word8    = 1
    ByteSize a        = TypeError (Text "The type " :<>: ShowType a :<>:
                                   Text " is not exportable.")

requires UndecidableInstances:

BS.hs:11:5: error:
    • The type family application ‘(TypeError ...)’
        is no smaller than the instance head
      (Use UndecidableInstances to permit this)
    • In the equations for closed type family ‘ByteSize’
      In the type family declaration for ‘ByteSize’

Obviously there's no real danger of undecidability here.

I tried changing the declaration of TypeError to

type family TypeError :: ErrorMessage -> b where

but it didn't help. Same error. Is that a bug?

Edited by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information