Skip to content

Instantly share code, notes, and snippets.

@FrigoEU
Created June 3, 2016 23:16
Show Gist options
  • Save FrigoEU/e371a954865b301ab6419bc0de4226bc to your computer and use it in GitHub Desktop.
Save FrigoEU/e371a954865b301ab6419bc0de4226bc to your computer and use it in GitHub Desktop.
manyMaybe :: forall m a. (Monad m) => ParserT String m a -> ParserT String m (Array a)
manyMaybe p = mapMaybe id <$> many (maybeP p)
maybeP :: forall m a. (Monad m) => ParserT String m a -> ParserT String m (Maybe a)
maybeP p = choice [(Just <$> p), (anyChar *> return Nothing)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment