Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Parsers for low-level productions in the Internet Message Format. These parsers are used throughout this library and may be useful to other programs.
Synopsis
- ci :: FoldCase s => Parser s -> Parser (CI s)
- data CI s
- mk :: FoldCase s => s -> CI s
- original :: CI s -> s
- wsp :: CharParsing f s a => f s a
- fws :: (Alternative (f s), CharParsing f s a) => f s s
- optionalFWS :: (Alternative (f s), CharParsing f s a, Monoid s) => f s s
- optionalCFWS :: (Alternative (f s), CharParsing f s a, SM s) => f s s
- crlf :: Alternative (f s) => CharParsing f s a => f s ()
- vchar :: CharParsing f s a => f s a
- word :: (Alternative (f s), CharParsing f s a, SM s) => f s s
- quotedString :: (Alternative (f s), CharParsing f s a, SM s) => f s s
- dotAtomText :: (Alternative (f s), CharParsing f s a) => f s (NonEmpty s)
- dotAtom :: (Alternative (f s), CharParsing f s a, SM s) => f s (NonEmpty s)
- localPart :: (Alternative (f s), CharParsing f s a, SM s) => f s s
- domainLiteral :: (Alternative (f s), CharParsing f s a, SM s) => f s s
- class IsChar a where
- char :: CharParsing f s a => Char -> f s a
- class IsChar a => CharParsing f s a | s -> a, a -> f s where
- type SM a = Monoid a
- isAtext :: IsChar c => c -> Bool
- isQtext :: IsChar c => c -> Bool
- isVchar :: IsChar c => c -> Bool
- isWsp :: IsChar c => c -> Bool
- (<<>>) :: (Semigroup m, Applicative f) => f m -> f m -> f m
- foldMany :: (Monoid m, Alternative f) => f m -> f m
- foldMany1 :: (Semigroup m, Alternative f) => f m -> f m
- foldMany1Sep :: (Semigroup m, Alternative f) => m -> f m -> f m
- skipTill :: Parser a -> Parser ()
- takeTill' :: Parser a -> Parser ByteString
- skipTillString :: ByteString -> Parser ()
- takeTillString :: ByteString -> Parser ByteString
Case-insensitive value parsers
ci :: FoldCase s => Parser s -> Parser (CI s) Source #
Modify a parser to produce a case-insensitive value
A CI s
provides Case Insensitive comparison for the string-like type
s
(for example: String
, Text
, ByteString
, etc.).
Note that CI s
has an instance for IsString
which together with the
OverloadedStrings
language extension allows you to write case insensitive
string literals as in:
> ("Content-Type" ::CI
Text
) == ("CONTENT-TYPE" ::CI
Text
) True
Instances
IsString EncodedParameterValue Source # | Parameter value with no language, encoded either in |
Defined in Data.MIME.Parameter | |
HasCharset EncodedParameterValue Source # | The default charset When encoding, 'utf-8' is always used, but if the whole string contains only ASCII characters then the charset declaration is omitted (so that it can be encoded as a non-extended parameter). |
Defined in Data.MIME.Parameter charsetName :: Getter EncodedParameterValue (Maybe CharsetName) Source # charsetData :: Getter EncodedParameterValue ByteString Source # charsetDecoded :: AsCharsetError e => CharsetLookup -> forall (p :: Type -> Type -> Type) (f :: Type -> Type). (Profunctor p, Contravariant f) => Optic' p f EncodedParameterValue (Either e (Decoded EncodedParameterValue)) Source # charsetDecoded' :: CharsetLookup -> forall (p :: Type -> Type -> Type) (f :: Type -> Type). (Profunctor p, Contravariant f) => Optic' p f EncodedParameterValue (Either CharsetError (Decoded EncodedParameterValue)) Source # charsetEncode :: Decoded EncodedParameterValue -> EncodedParameterValue Source # | |
Data s => Data (CI s) | |
Defined in Data.CaseInsensitive.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CI s -> c (CI s) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (CI s) # dataTypeOf :: CI s -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (CI s)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (CI s)) # gmapT :: (forall b. Data b => b -> b) -> CI s -> CI s # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CI s -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CI s -> r # gmapQ :: (forall d. Data d => d -> u) -> CI s -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> CI s -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CI s -> m (CI s) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CI s -> m (CI s) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CI s -> m (CI s) # | |
(IsString s, FoldCase s) => IsString (CI s) | |
Defined in Data.CaseInsensitive.Internal fromString :: String -> CI s # | |
Monoid s => Monoid (CI s) | |
Semigroup s => Semigroup (CI s) | |
(Read s, FoldCase s) => Read (CI s) | |
Show s => Show (CI s) | |
FoldCase (CI s) | |
Defined in Data.CaseInsensitive.Internal | |
NFData s => NFData (CI s) | |
Defined in Data.CaseInsensitive.Internal | |
Eq s => Eq (CI s) | |
Ord s => Ord (CI s) | |
Hashable s => Hashable (CI s) | |
Defined in Data.CaseInsensitive.Internal | |
type Decoded EncodedParameterValue Source # | |
Defined in Data.MIME.Parameter |
Abstract character parsers
wsp :: CharParsing f s a => f s a Source #
fws :: (Alternative (f s), CharParsing f s a) => f s s Source #
Folding white space (FWS). A run of one or more whitespace characters. Returns a single SPACE character.
optionalFWS :: (Alternative (f s), CharParsing f s a, Monoid s) => f s s Source #
FWS collapsed to a single SPACE character, or empty string
optionalCFWS :: (Alternative (f s), CharParsing f s a, SM s) => f s s Source #
CFWS collapsed to a single SPACE character, or empty string
crlf :: Alternative (f s) => CharParsing f s a => f s () Source #
Either CRLF or LF (lots of mail programs transform CRLF to LF)
vchar :: CharParsing f s a => f s a Source #
word :: (Alternative (f s), CharParsing f s a, SM s) => f s s Source #
quotedString :: (Alternative (f s), CharParsing f s a, SM s) => f s s Source #
dotAtomText :: (Alternative (f s), CharParsing f s a) => f s (NonEmpty s) Source #
dotAtom :: (Alternative (f s), CharParsing f s a, SM s) => f s (NonEmpty s) Source #
localPart :: (Alternative (f s), CharParsing f s a, SM s) => f s s Source #
domainLiteral :: (Alternative (f s), CharParsing f s a, SM s) => f s s Source #
char :: CharParsing f s a => Char -> f s a Source #
class IsChar a => CharParsing f s a | s -> a, a -> f s where Source #
singleton :: Char -> s Source #
satisfy :: (Char -> Bool) -> f s a Source #
takeWhile :: (Char -> Bool) -> f s s Source #
takeWhile1 :: (Char -> Bool) -> f s s Source #
Instances
CharParsing Parser ByteString Word8 Source # | |
Defined in Data.IMF.Syntax singleton :: Char -> ByteString Source # satisfy :: (Char -> Bool) -> Parser ByteString Word8 Source # takeWhile :: (Char -> Bool) -> Parser ByteString ByteString Source # takeWhile1 :: (Char -> Bool) -> Parser ByteString ByteString Source # | |
CharParsing Parser Text Char Source # | |
Constraint synonym to handle the Semigroup Monoid Proposal transition gracefully.
Helpers for building parsers
Semigroup and monoid folding combinators
(<<>>) :: (Semigroup m, Applicative f) => f m -> f m -> f m Source #
Combine two semigroup parsers into one
foldMany :: (Monoid m, Alternative f) => f m -> f m Source #
Parse zero or more values and fold them
foldMany1 :: (Semigroup m, Alternative f) => f m -> f m Source #
Parse one or more values and fold them
foldMany1Sep :: (Semigroup m, Alternative f) => m -> f m -> f m Source #
Parse one or more values and fold them with a separating element
General parsers and combinators
skipTill :: Parser a -> Parser () Source #
Skip until the given parser succeeds
@
λ> parseOnly (string "foo" *> skipTill (string ".") *> endOfInput) "foobar."
Right ()
@
takeTill' :: Parser a -> Parser ByteString Source #
Take until the parser matches (fails if it never matches).
@
λ> parseOnly (takeTill' (string "bar") <* endOfInput) "foobar"
Right "foo"
@
Efficient string search
skipTillString :: ByteString -> Parser () Source #
Efficient skip, using Boyer-Moore to locate the pattern.
@
λ> parseOnly (string "foo" *> skipTillString "." *> endOfInput) "foobar."
Right ()
@
takeTillString :: ByteString -> Parser ByteString Source #
Efficient take, using Boyer-Moore to locate the pattern.
@
λ> parseOnly (takeTillString "bar" <* endOfInput) "foobar"
Right "foo"
@