bar = ((put' 7) >>> get') &&& get'
, .

do, proc , , >>=, .
, , x , :
bar' = proc x -> do
wasput <- put' 7 >>> get' -< x
justgot <- get' -< x
returnA -< (wasput,justgot)
, ,
bar'' = proc x -> do
wasput <- get' <<< put' 7 -< x
justgot <- get' -< x
returnA -< (wasput,justgot)
test :
test s b = (flip runStateA) s b
,
ghci> test bar 3 5
((7,3),3)
ghci> test bar' 3 5
((7,3),3)
ghci> test bar'' 3 5
((7,3),3)
>>>?
, (>>>):
bar''' = proc x -> do
put7 <- put' 7 -< x
wasput <- get' -< put7
justgot <- get' -< x
returnA -< (wasput,justgot)
oops, no:
ghci> test bar''' 3 5
((3,3),3)
, , put' 7 get', >>> <<<.
, . ...
, , , , , , :
first (f >>> g) = first f >>> first g
dup :: Arrow a => a t (t, t)
dup = arr (\x -> (x,x))
ghci> test (dup >>> (first (put' 7 >>> get'))) 1 3
((7,3),1)
ghci> test (dup >>> (first (put' 7) >>> first get')) 1 3
((1,3),1)
, put' 7 first, !
:
, , , , .
Unfortunately, whist is very interesting and extremely distracting, this is not a real Arrow.