Composite typeclasses in Haskell

Viewed 68

Is there any practical difference between

class (From a b, To a b) => IsomorphismFromTo a b 
instance (From a b, To a b) => IsomorphismFromTo a b 

and

type IsomorphismFromTo a b = (From a b, To a b)

where no instance of IsomorphismFromTo a b is provided apart from the trivial one, apart from the ability to quantify

--type IsomorphismFromTo a b = (From a b, To a b) -- fails
class (From a, To a) => IsomorphismFromTo a b  -- works


type IsomorphismFromTo1 f g = forall x. IsomorphismFromTo (f x) (g x) 
-- "You can't specify an instance for a tuple constraint" with the constraint synonym
0 Answers
Related