
Hi, friends, I've built GHC from darcs, and... Could anybody tell me, what's the purpose of Arrow[1] not having `>>>' method? 1. http://darcs.haskell.org/packages/base/Control/Arrow.hs $ ghci GHCi, version 6.9.20080104: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Prelude> :m + Control.Arrow Prelude Control.Arrow> :i Arrow class (Control.Category.Category a) => Arrow a where arr :: (b -> c) -> a b c pure :: (b -> c) -> a b c first :: a b c -> a (b, d) (c, d) second :: a b c -> a (d, b) (d, c) (***) :: a b c -> a b' c' -> a (b, b') (c, c') (&&&) :: a b c -> a b c' -> a b (c, c') -- Defined in Control.Arrow instance Arrow (->) -- Defined in Control.Arrow instance (Monad m) => Arrow (Kleisli m) -- Defined in Control.Arrow Prelude Control.Arrow> Leaving GHCi. I can't build[2] arrows-0.3 package without `>>>' in Arrow. 2. vvv@fun:~/src/arrows$ darcs w { hunk ./Control/Arrow/Operations.hs 36 +import Control.Category ((>>>)) hunk ./Control/Arrow/Transformer/CoState.hs 23 +import Control.Category ((>>>)) } vvv@fun:~/src/arrows$ runhaskell Setup build Preprocessing library arrows-0.3... Building arrows-0.3... [ 3 of 12] Compiling Control.Arrow.Transformer.CoState ( Control/Arrow/Transformer/CoState.hs, dist/build/Control/Arrow/Transformer/CoState.o ) Control/Arrow/Transformer/CoState.hs:29:7: `>>>' is not a (visible) method of class `Arrow' The question arises "should I?", but this is one of lambdabot's[3] depencies. 3. http://code.haskell.org/lambdabot/ Thanks a lot! -- vvv

On Jan 23, 2008 12:20 PM, Valery V. Vorotyntsev
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.
--
Dave Menendez

On 1/23/08, David Menendez
On Jan 23, 2008 12:20 PM, Valery V. Vorotyntsev
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

Valery V. Vorotyntsev wrote:
On 1/23/08, David Menendez
wrote: On Jan 23, 2008 12:20 PM, Valery V. Vorotyntsev
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?
Well, without looking at your code, generally all you have to do is 1) move the definition of (>>>) to Category and rename it to (.) after flipping the arguments. 2) define the id method of Category which is just (arr id) or returnA. So essentially instance Arrow (Foo a) where a >>> b = compose a b pure f = ... first a = ... becomes instance Arrow (Foo a) where pure f = ... first a = ... instance Category (Foo a) where id = arr id a . b = compose b a That's it. It's too bad there's no way to do this automatically in the libraries, but it could be noted in the API docs. Pete
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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.
participants (3)
-
David Menendez
-
Peter Gavin
-
Valery V. Vorotyntsev