[Haskell-cafe] Restricted categories

Alexander Solla ajs at 2piix.com
Sat Feb 20 16:03:54 EST 2010


On Feb 20, 2010, at 10:29 AM, Sjoerd Visscher wrote:

> I don't understand this, as I thought the constraints the error is  
> complaining about is just what withConstraintsOf g should provide.
> I guess there's something about the Suitable trick that I don't  
> understand, or possibly the type families Fst and Snd are biting me.
>
> Who can help me out? Thanks.

You specifically ask withConstraintsOf to accept only Suitable2's when  
you say

> withConstraintsOf :: Suitable2 m a b => m a b -> (Constraints m a b - 
> > k) -> k

But you aren't saying that the argument of withConstraintsOf IS a  
Suitable2, when you say:

> instance (RCategory c1, RCategory c2) => RCategory (c1 :***: c2) where
> id = withResConstraints $ \ProdConstraints -> id :***: id
> -- f@(f1 :***: f2) . g@(g1 :***: g2) =
> --   withResConstraints $ \ProdConstraints ->
> --   withConstraintsOf f $ \ProdConstraints ->
> --   withConstraintsOf g $ \ProdConstraints ->
> --   (f1 . g1) :***: (f2 . g2)


You need to make a type class instance for Suitable2 for whatever type  
\ProdConstraints -> ... represents.

For comparison, try:

 > data Unordered = A | B | C

 > A <= B
    No instance for (Ord Unordered)
      arising from a use of `<=' at <interactive>:1:0-5
    Possible fix: add an instance declaration for (Ord Unordered)
    In the expression: A <= B
    In the definition of `it': it = A <= B

and now:

 > data Ordered = A | B | C deriving (Show, Eq, Ord) -- (easier than  
writing an instance for Eq, Ord)
 > A <= B
     True


More information about the Haskell-Cafe mailing list