Here are some examples of things you can do by reusing the lens machinery:
-- Insert a 1 after the 5th element
over (Pipes.Parse.splitAt 5) (<* yield 1)
-- Replace the first group of consecutive matching elements with 1
set (Pipes.Parse.group . Pipes.Extras.output) 1
-- Replace each line with "FOO"
over (Pipes.ByteString.lines . Pipes.Group.individually) (\p ->
yield "FOO" >> for p discard)
On 03/06/2016 08:31 AM, Thomas Wilkinson wrote:
Do you sometimes need to `set (span even)` or `set group`? When is
that helpful?
On Sunday, March 6, 2016 at 4:14:21 PM UTC, Gabriel Gonzalez wrote:
I would prefer to keep them the way they are, because the full
`Lens` functionality isn’t used just for `zoom` but also for other
utilities like `over` or `set`. It’s easier to just warn users
that a lens is improper than to create parallel versions of every
utility that a person might want to use with these `Lens`es.
On Mar 6, 2016, at 6:06 AM, Thomas Wilkinson
<thomas.s....@gmail.com <javascript:>> wrote:
I am slightly freaked out by the `Lens`es provided by
`Pipes.Parse` being 'improper'. Could they not be `Getter`s
instead?
type Splitter a m = forall x. Getter (Producer a m x)
(Producer a m (Producer a m x))
-- Should have " join . view sp == id " for any sp ::
Splitter a m and p :: Producer a m r
span :: Monad m => (a -> Bool) -> Splitter a m
splitAt :: Monad m => Int -> Splitter a m
groupBy :: Monad m => (a -> a -> Bool) -> Splitter a m
group :: (Monad m, Eq a) => Splitter a m
-- would replace `zoom`
split :: Splitter a m -> Parser a m r -> Parser a m r
split sp st = StateT $ \p -> fmap (fmap join) (runStateT st
(p^.sp))
This means that users would sometimes have to use `zoom` and
sometimes have to use `split`, which might be annoying. But it
feels better than having fake `Lens`es somehow.
--
You received this message because you are subscribed to the
Google Groups "Haskell Pipes" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to haskell-pipe...@googlegroups.com <javascript:>.
To post to this group, send email to haskel...@googlegroups.com
<javascript:>.
--
You received this message because you are subscribed to the Google
Groups "Haskell Pipes" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to haskell-pipes+unsubscr...@googlegroups.com
<mailto:haskell-pipes+unsubscr...@googlegroups.com>.
To post to this group, send email to haskell-pipes@googlegroups.com
<mailto:haskell-pipes@googlegroups.com>.
--
You received this message because you are subscribed to the Google Groups "Haskell
Pipes" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to haskell-pipes+unsubscr...@googlegroups.com.
To post to this group, send email to haskell-pipes@googlegroups.com.