Arrow without `>>>'

Valery V. Vorotyntsev valery.vv at gmail.com
Thu Jan 24 08:10:39 EST 2008


On 1/23/08, David Menendez <dave at zednenem.com> wrote:
> On Jan 23, 2008 12:20 PM, Valery V. Vorotyntsev <valery.vv at gmail.com> wrote:
> > I've built GHC from darcs, and...
> > Could anybody tell me, what's the purpose of Arrow[1] not having `>>>'
> > method?
>
> It's derived from the Category superclass.

Yes, it is.

The right question: how to build `arrows' in such circumstances?

Here go 2 changes I made to `CoState.hs' accompanied by the
error messages. :) Unfortunately, I'm not arrow-capable enough to
make _proper_ changes to the code and satisfy GHC... Any help?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Change #1:

$ darcs w Control/Arrow/Transformer/CoState.hs
What's new in "Control/Arrow/Transformer/CoState.hs":

{
hunk ./Control/Arrow/Transformer/CoState.hs 23
+import Control.Category ((>>>))
}

--------------------------------------------------
Error #1:

Control/Arrow/Transformer/CoState.hs:29:7:
    `>>>' is not a (visible) method of class `Arrow'
Failed, modules loaded: Control.Arrow.Operations.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Change #2:

$ darcs diff -u Control/Arrow/Transformer/CoState.hs
--- old-arrows/Control/Arrow/Transformer/CoState.hs     2008-01-24
14:54:29.852296559 +0200
+++ new-arrows/Control/Arrow/Transformer/CoState.hs     2008-01-24
14:54:29.852296559 +0200
@@ -20,12 +20,13 @@

 import Control.Arrow
 import Control.Arrow.Operations
+import Control.Category ((>>>))

  newtype CoStateArrow s a b c = CST (a (s -> b) (s -> c))

  instance Arrow a => Arrow (CoStateArrow s a) where
        arr f = CST (arr (f .))
-       CST f >>> CST g = CST (f >>> g)
+--     CST f >>> CST g = CST (f >>> g)
        first (CST f) = CST (arr unzipMap >>> first f >>> arr zipMap)

  zipMap :: (s -> a, s -> b) -> (s -> (a,b))

--------------------------------------------------
Error#2:

Control/Arrow/Transformer/CoState.hs:27:0:
    Could not deduce (Control.Category.Category (CoStateArrow s a))
      from the context (Arrow a)
      arising from the superclasses of an instance declaration
                   at Control/Arrow/Transformer/CoState.hs:27:0
    Possible fix:
      add (Control.Category.Category
             (CoStateArrow s a)) to the context of
        the instance declaration
      or add an instance declaration for
         (Control.Category.Category (CoStateArrow s a))
    In the instance declaration for `Arrow (CoStateArrow s a)'
Failed, modules loaded: Control.Arrow.Operations.

Thank you.

-- 
vvv


More information about the Libraries mailing list