[Haskell-cafe] Functor in terms of Arrow

Peter Gammie peteg42 at gmail.com
Sun Feb 19 00:08:01 CET 2012


On 19/02/2012, at 3:21 AM, Tom Schouten wrote:

> Does AFunctor below have a standard name?  It's a generalization of
> the Functor class in terms of Arrow instead of (->):
>      fmap  :: Functor f           => (i -> o) -> f i  ->  f o
>      afmap :: Arrow a, AFunctor f => a i o    -> a (f i) (f o)
> It pops up in less general form (AFunctor = []) in iterated functions
> (difference equations / state space models), where the arrow is the
> update function parameterized by state type:
>  data Iter s i o = Iter ((s,i) -> (s,o))
>  instance Arrow (Iter s)

I think you can work with Arrow transformers instead. See:


It may be that you can generalise to arbitrary functors, but satisfying the Arrow laws may require some care.



More information about the Haskell-Cafe mailing list