Question about arrows

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.

On 8/3/07, Lewis-Sandy, Darrell
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
There isn't because that type signature isn't valid in general. Consider the Kleisli arrows, for instance: how would you write eval :: Kleisli (State Int) Int Int -> Int -> Int? You need to get the initial state from somewhere... similar problems would exist for Kleisli IO Int Int. /g -- The man who'd introduced them didn't much like either of them, though he acted as if he did, anxious as he was to preserve good relations at all times. One never knew, after all, now did one now did one now did one.

On 8/3/07, Lewis-Sandy, Darrell
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
You could always use the ArrowEval class. Granted, it doesn't exist, so you'd have to write it, but it should serve your purposes. class ArrowEval a where eval :: a b c -> b -> c instance ArrowEval (->) where eval = ... instance ArrowEval YourPartial where eval = ... (That's off the cuff, so I probably didn't get the syntax correct.) Does that fit your problem? But like Mr. Morris said, eval isn't valid for every arrow, so you can only define instances of ArrowEval where it is valid. Bryan
participants (3)
-
Bryan Burgers
-
J. Garrett Morris
-
Lewis-Sandy, Darrell