Skip to content

Nullary type classes

GHC supports MultiParamTypeClasses with two or more parameters, but it explicitly rejects classes with no parameters. There doesn't seem to be a good reason for that.

Some example uses that came up in IRC:

isPrime :: RiemannHypothesis => Integer -> Bool

unsafePerformIO :: Unsafe => IO a -> a

The main reason to allow it is probably that it's a pointless restriction, like EmptyDataDecls. In fact, the simplest implementation for this patch consists of deleting one line of code. The attached patch is slightly bigger because it also fixes error messages (I also included a detabbing patch).

If necessary this can be made a separate LANGUAGE flag -- this patch just folds it into MultiParamTypeClasses.

Trac metadata
Trac field Value
Version 7.6.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information