[Haskell-cafe] checking types with type families

Simon Peyton-Jones simonpj at microsoft.com
Thu Jul 1 13:54:11 EDT 2010

|  Well, from looking at the documentation, it looks like I could maybe
|  use a type family if I could write:
|  class (DerivedOf a ~ derived) => Typecheck a derived where
|   ...

That's the right idiom yes. But see my message of a few minutes ago...  It's neater still to remove the 'derived' parameter altogether, which you can do with uni-directional fundeps. Thus instead of
	class Typecheck a derived where
	  op :: a -> derived
you have
	class Typecheck a where
	  type Derived a
	  op :: a -> Derived a

|  Presumably then I could combine functions 'Typecheck a derived'
|  constraints without getting lots of "Could not deduce (Typecheck a
|  derived3) from the context (Typecheck a derived13)" errors.  I'm only
|  guessing though, because it looks like it's not implemented yet as of
|  6.12.3.

Correct.  These equality superclasses will work in 6.14 and (in a few weeks) in the HEAD, but not in 6.12. 

But you may not need them if you have unidirectional fundeps.


More information about the Haskell-Cafe mailing list