pup-0.1.1: Invertible format descriptors
Safe HaskellNone
LanguageGHC2021

Text.Pup.Class.Char

Description

Format descriptors specialised to the token type Char. See also Text.Megaparsec.Char.

Synopsis

Numbers

digit :: (Stacked m, Monad m, Tokens Char chunk m) => m (Int -> r) r Int Source #

Decimal digit. To manipulate the raw Char instead, use digitChar.

digitChar :: Tokens Char chunk m => m (Char -> r) r Char Source #

A Char standing for a decimal digit. You can return the digit at an Int with digit.

nat :: (Stacked m, Alternative m, Tokens Char chunk m) => m (Int -> r) r Int Source #

A (maximal) sequence of decimal digits interpreted as a natural number

Individual characters

char :: Tokens Char chunk m => Char -> m r r Char Source #

Type constrainted version of single

anyChar :: Tokens Char chunk m => m (Char -> r) r Char Source #

Type constrainted version of anyChar

Read and show

read :: (Applicative m, Stacked m, Read a, Show a) => m (a -> r) (String -> r) (String -> a) Source #

A total lead based using read and show for the respective directions. It is the responsibility of the parser to ensure that the input is the domain of read (the printer, on the other hand always succeeds). Otherwise the read descriptor will fail with error.

For a format descriptor capable of failing with a parse error, see readM.

readM :: (MonadFail m, Stacked m, Read a, Show a) => String -> m (a -> r) (String -> r) a Source #

A format descriptor using read and show for the respective directions. If read fails, then a parse error is reported (with the same message as readEither). In exchange readM, compared to read, must use a monadic control flow.