
Dear HC, 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) More concretely:
afmap :: ((s,i) -> (s, o)) -> (s,[i]) -> (s,[o]) afmap f (s,[]) = (s,[]) afmap f (s0, i:is) = (sn, o:os) where (s1, o) = f (s0,i) (sn, os) = afmap f (s1, is)
f (s,i) = (s', s') where s' = s + i is = [1,1,1,1,1] os = afmap f (0,is) -- (5,[1,2,3,4,5])
Cheers, Tom

Tom, 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: http://hackage.haskell.org/packages/archive/arrows/latest/doc/html/Control-A... It may be that you can generalise to arbitrary functors, but satisfying the Arrow laws may require some care. cheers peter -- http://peteg.org/
participants (2)
-
Peter Gammie
-
Tom Schouten