1 Oct 2012 20:05
Is inspectable recursion in Arrows possible?
Alessandro Vermeulen <a.vermeulen <at> students.uu.nl>
2012-10-01 18:05:19 GMT
2012-10-01 18:05:19 GMT
Dear all,
I am trying to find a way to translate normal recursive notation such
as the |fib| function below to an arrow, retaining as much of the
structure of the recursive notation as possible. In addition I would
like to inspect the arrow. For this I created a datatype containing a
constructor for each Arrow{..} class:
Fib:
> fib 0 = 0
> fib 1 = 1
> fib n = fib (n-2) + fib (n-1)
My R datatype, the instances for this datatype consist of the mapping
to the appropriate constructor:
> data R x y where
> -- Category
> Id :: R a a
> Comp :: R b c -> R a b -> R a c
> -- Arrow
> Arr :: (a -> b) -> R a b
> Split :: R b c -> R b' c' -> R (b,b') (c,c')
> Cache :: (a -> a -> Bool) -> R a a
> -- ArrowChoice
> Choice :: R b c -> R b' c' -> R (Either b b') (Either c c')
> -- ArrowLoop
> Loop :: R (b, d) (c, d) -> R b c
> -- ArrowApply
> Apply :: R (R b c, b) c
(Continue reading)
RSS Feed