I am trying to define the left operator for a CPS arrow of type:

newtype CPSFunctor ans a b c = CPS ((a c ans) -> (a b ans))

This is the definition given by John Hughes for first:

first (CPS f) = CPS $ \k -> arr (\(b,d) -> (f (arr (\c -> (c,d)) >>> k),b)) >>> app

So I try and apply this to left and get:

left (CPS f) = CPS $ \k -> arr (\z -> case z of
        Left x -> (f (arr Left >>> k),x)
        Right x -> (arr Right >>> k,x)) >>> app

But when I compile (with ghc-6.0) I get:

    Inferred type is less polymorphic than expected
        Quantified type variable `d' is unified with another quantified type variable 
`b'
    When trying to generalise the type inferred for `left'
        Signature type:     forall ans a.
                            (ArrowApply a, ArrowChoice a) =>
                            forall b1 c1 d1.
                            CPSFunctor ans a b1 c1
                            -> CPSFunctor ans a (Either b1 d1) (Either c1 d1)
        Type to generalise: forall b1 c1 d1.
                            CPSFunctor ans a b1 c1
                            -> CPSFunctor ans a (Either b1 d1) (Either c1 d1)
    In the instance declaration for `ArrowChoice (CPSFunctor ans a)'

Hughes says in his paper that "CPS arrows ... can of course support dynamic choice" - 
so where am I going wrong with my definition? 

Any help greatly appreciated... 

        Regards,
        Keean Schupke.
_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to