[Haskell-cafe] Multi-param typeclass vs locally constrained typeclass methods

Jacques Carette carette at mcmaster.ca
Wed Sep 18 14:21:51 CEST 2013


Could someone please explain what the difference (if any!), in semantics 
is between

class Foo f => Bar f g where
   method1 :: f a -> g a

and

class Bar' g where
   method2 :: Foo f => f a -> g a

?  Maybe the translation of the above to something lower level might 
help.  [Note: "f a -> g a" is just an example, and is not meaningful to 
the question].

The best answer would contain a design guideline for typeclasses, which 
would spell out conditions in which to use each variant.

Jacques





More information about the Haskell-Cafe mailing list