PROPOSAL: Some more 'Applicative' combinators
Iavor Diatchki
iavor.diatchki at gmail.com
Sun Jan 6 16:35:41 EST 2008
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
More information about the Libraries
mailing list