[Haskell-cafe] Question about arrows
Lewis-Sandy, Darrell
darrelll at amgen.com
Fri Aug 3 13:11:37 EDT 2007
Is there a class property of the Control.Arrow class that represents the
evaluatation of an arrow:
eval :: (Arrow a)=>a b c->b->c
I am writing some higher order code that I would like to work with either
functions or partial functions (implemented as balanced binary search trees)
and don't want to write separate instances for each concrete arrow type.
For example, consider the example below:
divideAndConquer::( Arrow a, Bifunctor m)=>(m c y->y)->a b c->(x->m b
x)->x->y
divideAndConquer combine solve divide = combine.(bimap (eval solve)
(divideAndConquer combine solve divide)).divide
that implements datatype generic divide and conquer. divide encodes how to
decompose a problem of type x into subproblems, solve encodes how to solve
indivisible sub-problems, and combine encodes how to put the sub-solutions
together. The branching strategy is encoded in the bifunctor, and the use
of eval faciliatates either evaluating a function or looking up solutions in
a table.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070803/d6b27d8c/attachment.htm
More information about the Haskell-Cafe
mailing list