| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Text.ProtocolBuffers.Header
Description
This provides what is needed for the output of hprotoc to
compile. This and the Prelude will both be imported qualified as
P', the prime ensuring no name conflicts are possible.
- append :: Seq a -> a -> Seq a
- emptyBS :: ByteString
- pack :: [Char] -> ByteString
- fromMaybe :: a -> Maybe a -> a
- ap :: Monad m => m (a -> b) -> m a -> m b
- fromDistinctAscList :: [a] -> Set a
- member :: Ord a => a -> Set a -> Bool
- throwError :: MonadError e m => forall a. e -> m a
- catchError :: MonadError e m => forall a. m a -> (e -> m a) -> m a
- choice :: Stream s m t => [ParsecT s u m a] -> ParsecT s u m a
- sepEndBy :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
- spaces :: Stream s m Char => ParsecT s u m ()
- try :: ParsecT s u m a -> ParsecT s u m a
- module Data.Generics
- module Text.ProtocolBuffers.Basic
- module Text.ProtocolBuffers.Extensions
- module Text.ProtocolBuffers.Identifiers
- module Text.ProtocolBuffers.Reflections
- module Text.ProtocolBuffers.TextMessage
- module Text.ProtocolBuffers.Unknown
- module Text.ProtocolBuffers.WireMessage
Documentation
emptyBS :: ByteString Source #
pack :: [Char] -> ByteString #
O(n) Convert a String into a ByteString.
fromMaybe :: a -> Maybe a -> a #
The fromMaybe function takes a default value and and Maybe
value. If the Maybe is Nothing, it returns the default values;
otherwise, it returns the value contained in the Maybe.
Examples
Basic usage:
>>>fromMaybe "" (Just "Hello, World!")"Hello, World!"
>>>fromMaybe "" Nothing""
Read an integer from a string using readMaybe. If we fail to
parse an integer, we want to return 0 by default:
>>>import Text.Read ( readMaybe )>>>fromMaybe 0 (readMaybe "5")5>>>fromMaybe 0 (readMaybe "")0
fromDistinctAscList :: [a] -> Set a #
O(n). Build a set from an ascending list of distinct elements in linear time. The precondition (input list is strictly ascending) is not checked.
throwError :: MonadError e m => forall a. e -> m a #
Is used within a monadic computation to begin exception processing.
catchError :: MonadError e m => forall a. m a -> (e -> m a) -> m a #
A handler function to handle previous errors and return to normal execution. A common idiom is:
do { action1; action2; action3 } `catchError` handlerwhere the action functions can call throwError.
Note that handler and the do-block must have the same return type.
choice :: Stream s m t => [ParsecT s u m a] -> ParsecT s u m a #
choice ps tries to apply the parsers in the list ps in order,
until one of them succeeds. Returns the value of the succeeding
parser.
sepEndBy :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a] #
sepEndBy p sep parses zero or more occurrences of p,
separated and optionally ended by sep, ie. haskell style
statements. Returns a list of values returned by p.
haskellStatements = haskellStatement `sepEndBy` semi
spaces :: Stream s m Char => ParsecT s u m () #
Skips zero or more white space characters. See also skipMany.
try :: ParsecT s u m a -> ParsecT s u m a #
The parser try p behaves like parser p, except that it
pretends that it hasn't consumed any input when an error occurs.
This combinator is used whenever arbitrary look ahead is needed.
Since it pretends that it hasn't consumed any input when p fails,
the (<|>) combinator will try its second alternative even when the
first parser failed while consuming input.
The try combinator can for example be used to distinguish
identifiers and reserved words. Both reserved words and identifiers
are a sequence of letters. Whenever we expect a certain reserved
word where we can also expect an identifier we have to use the try
combinator. Suppose we write:
expr = letExpr <|> identifier <?> "expression"
letExpr = do{ string "let"; ... }
identifier = many1 letterIf the user writes "lexical", the parser fails with: unexpected
'x', expecting 't' in "let". Indeed, since the (<|>) combinator
only tries alternatives when the first alternative hasn't consumed
input, the identifier parser is never tried (because the prefix
"le" of the string "let" parser is already consumed). The
right behaviour can be obtained by adding the try combinator:
expr = letExpr <|> identifier <?> "expression"
letExpr = do{ try (string "let"); ... }
identifier = many1 lettermodule Data.Generics
module Text.ProtocolBuffers.Basic
module Text.ProtocolBuffers.Unknown