PROPOSAL: Some more 'Applicative' combinators
Seth Kurtzberg
seth at cql.com
Sun Jan 6 18:34:40 EST 2008
Can you show some code fragments demonstrating how the combinators are used? I find it easier to understand the underlying concepts when I have not only the signature and implementation but an example of a typical use. It doesn't have to be working code, and it might even be pseudo code. (I'm not sure whether other Haskell folks feel the same way.)
On Sun, 6 Jan 2008 13:35:41 -0800
"Iavor Diatchki" <iavor.diatchki at gmail.com> wrote:
> Hello,
> I propose that we add the following combinators to the
> 'Control.Applicative' module:
>
> skipMany :: (Alternative f) => f a -> f ()
> skipMany p = skipSome p <|> pure ()
>
> skipSome :: (Alternative f) => f a -> f ()
> skipSome p = p *> skipMany p
>
> endBy :: (Alternative f) => f a -> f b -> f [a]
> endBy p s = many (p <* s)
>
> endBy1 :: (Alternative f) => f a -> f b -> f [a]
> endBy1 p s = some (p <* s)
>
> sepBy :: (Alternative f) => f a -> f v -> f [a]
> sepBy p s = sepBy1 p s <|> pure []
>
> sepBy1 :: (Alternative f) => f a -> f v -> f [a]
> sepBy1 p s = (:) <$> p <*> many (s *> p)
>
>
> Any objections? Deadline for discussion is 2 weeks from now, which
> would be the 20th of Jan.
>
> -Iavor
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
--
Seth Kurtzberg <seth at cql.com>
Hardware/Software/Driver Engineering
More information about the Libraries
mailing list