packages feed

parcom-lib 0.3.0.1 → 0.4.0.0

raw patch · 2 files changed

+16/−1 lines, 2 files

Files

Text/Parcom/Combinators.hs view
@@ -4,11 +4,14 @@ , many, many1, manySepBy , times , skip+, possibly ) where  import Text.Parcom.Core import Text.Parcom.Internal+import Control.Monad (liftM)+import Data.Maybe (fromMaybe)  -- | Walk a list of options, return the first one that succeeds. choice :: (Monad m, Stream s t) => [ParcomT s t m a] -> ParcomT s t m a@@ -76,3 +79,15 @@ -- | Ignore the result of a parser. skip :: Monad m => ParcomT s t m a -> ParcomT s t m () skip p = p >> return ()++-- | Optional parsing to Maybe+possibly :: Monad m => ParcomT s t m a -> ParcomT s t m (Maybe a)+possibly p = Just `liftM` p <|> return Nothing++-- | Optional parsing with default+optional :: Monad m => a -> ParcomT s t m a -> ParcomT s t m a+optional d p = fromMaybe d `liftM` possibly p++-- | Optional parsing, ignoring (but consuming) result+option :: Monad m => ParcomT s t m a -> ParcomT s t m ()+option p = skip $ optional undefined p
parcom-lib.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                parcom-lib-version:             0.3.0.1+version:             0.4.0.0 synopsis:            A simple parser-combinator library, a bit like Parsec but without the frills description:         Parcom provides parser combinator functionality in a string-type-agnostic way;                      it supports strict ByteStrings (with Word8 tokens) and any list type (with