Tue Aug 16 15:34:48 CEST 2011

Arrow class

Let's try to define an Arrow instance.  It turnes out to be quite
straightforward.  Note that is already has (.) and id from Category.

_arr :: (a -> b) -> Opr () a b  
_arr f a =  _return $ f a

_first :: Opr s a b -> Opr s (a, z) (b, z)
_first opr = opr' where
  opr' (a,z) = (s0, u') where
    (s0, u) = opr a
    u' s = (s', (b, z)) where
      (s', b) = u s

instance Arrow Operator where
  arr   = Operator . _arr
  first (Operator a) = Operator $ _first a

So this is the Kleisli Arrow of the Monad I can't implement because of
type inference problems.

The _first can probably be implemented in terms of _bind.

_first arr (a, z) = do
   b <- arr a
   return (b, z)