[Haskell-cafe] Lack of expressiveness in kinds?

oleg at pobox.com oleg at pobox.com
Thu Mar 15 20:09:26 EDT 2007

Andrew Wagner wrote
> data Foo a = Bar a
> data (Ord a) => Baz a = Bah a
> Note that both of these have kind * -> *. However, Baz could never be
> an instance of monad, because there is a restriction on the types it
> can operate on.

There is a wide-spread opinion that one ought not to give context to a
data type declaration (please search for `restricted datatypes
Haskell'). Someone said that in GHC typechecker such contexts called
stupidctx. There has been a proposal to remove that feature from
Haskell, although I like it as a specification tool.  John Hughes
wrote a paper about a better use for that feature:

  John Hughes. 1999. Restricted datatypes in Haskell.
  In Proceedings of the 1999 Haskell workshop, ed. Erik Meijer. Technical
  Report UU-CS-1999-28, Department of Computer Science, Utrecht University.
That proposal has not been implemented.

One should point out that restricted monads are available in
Haskell right now:

It seems one can even use the do-notation for them, with the help of
`rebindable syntax' feature of GHC. This is because the types of
restricted bind and return are exactly the same as those of regular
bind and return. Only the `Monad' constraint is a bit different.
Restricted monads are the strict super-set of the ordinary monads, so
the backwards compatibility is maintained.

One almost wishes for a fuller integration of restricted monads into
the language...

More information about the Haskell-Cafe mailing list