[Haskell-cafe] ArrowLoop and streamprocessors

David Menendez dave at zednenem.com
Thu Mar 31 19:21:56 CEST 2011


On Thu, Mar 31, 2011 at 11:01 AM, Matthew Steele <mdsteele at alum.mit.edu> wrote:
> On Mar 30, 2011, at 5:29 PM, Mathijs Kwik wrote:
>
>> So loop really doesn't seem to help here, but I couldn't find another
>> way either to feed outputs back into the system.
>> What I need is:
>> Either A B ~> Either C B -> A ~> C
>>
>> Does such a thing exist?
>
> Based on your description, it sounds to me like you want a loop such that if
> a B is generated at the end, you send it back to the start and execute your
> arrow a second time.  Is that in fact what you intended?  However, the docs
> for ArrowLoop's loop function make it clear that it executes the arrow only
> once:
>
>  http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.3.1.0/Control-Arrow.html#v:loop
>
> If your arrows are instances of ArrowApply, I believe you could use app to
> implement the combinator you want.

If your arrow's combinators are lazy enough, you can do something like this:

foo :: ArrowChoice (~>) => (Either a b ~> Either c b) -> (a ~> c)
foo f = (id ||| bar) . f . arr Left
	where
	bar = (id ||| bar) . f . arr Right

But maybe Arrow isn't the proper abstraction. Perhaps something more
similar to Fudgets is appropriate?

-- 
Dave Menendez <dave at zednenem.com>
<http://www.eyrie.org/~zednenem/>



More information about the Haskell-Cafe mailing list