[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell-cafe
Subject:    Re: [Haskell-cafe] ANNOUNCE: pipes-core 0.1.0
From:       Paolo Capriotti <p.capriotti () gmail ! com>
Date:       2012-04-17 22:11:55
Message-ID: CALMmMjaqf_+NLnFbjbBC5MEy7iUoQ2qD68O_yt_oDgXE24+Zrw () mail ! gmail ! com
[Download RAW message or body]

On Tue, Apr 17, 2012 at 4:10 PM, Chris Smith <cdsmith@gmail.com> wrote:
> One thing that Gabriel and
> Michael have been talking about, though, that seems to be missing
> here, is a way for a pipe to indicate that it's finished with its
> upstream portion, so that upstream finalizers can be immediately run
> without waiting for the downstream parts of the pipe to complete.

Yes, that is indeed a limitation of pipes-core, but it's still
possible to achieve early finalization when needed, by explicitly
returning a "continuation" pipe. The following operator

(>!>) :: Monad m
      => Pipe a b m r
      -> Pipe b c m (Pipe a c m r)
      -> Pipe a c m r
p1 >!> p2 = do
  r0 <- (Left <$> p1) >+> (Right <$> p2)
  case r0 of
    Left r -> return r
    Right p' -> p'

could be used to compose such a pipe. Alternatively, one can use
'Control.Pipe.Zip.controllable' together with 'loopP' (there's a
similar example in pipes-extra/Examples/finalizers/complex.hs).

Unfortunately, both approaches are not compositional. They require you
to structure the whole pipeline around them.

I suspect it might be possible to incorporate these ideas into the
Pipe type without losing associativity, but I don't have any
motivating examples where this feature would actually be useful. Do
you have anything in mind, Chris?

BR,
Paolo

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic