HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Modulemegaparsec-9.5.0Haskell2010

Text.Megaparsec.Char

Commonly used character parsers.

Contents
  1. Simple parsers
  2. Categories of characters
  3. Single character
  4. Sequence of characters
Synopsis
  • Packagemegaparsec-9.5.0
  • Exports32
  • LanguageHaskell2010
  • LicenceBSD-2-Clause
  • SourceChar.hs

Simple parsers

Categories of characters

valueupperChar :: (MonadParsec e s m, Token s ~ Char) => m (Token s)

Parse an upper-case or title-case alphabetic Unicode character. Title case is used by a small number of letter ligatures like the single-character form of Lj.

valueletterChar :: (MonadParsec e s m, Token s ~ Char) => m (Token s)

Parse an alphabetic Unicode character: lower-case, upper-case, or title-case letter, or a letter of case-less scripts/modifier letter.

valuealphaNumChar :: (MonadParsec e s m, Token s ~ Char) => m (Token s)

Parse an alphabetic or numeric digit Unicode characters.

Note that the numeric digits outside the ASCII range are parsed by this parser but not by digitChar. Such digits may be part of identifiers but are not used by the printer and reader to represent numbers.

valuelatin1Char :: (MonadParsec e s m, Token s ~ Char) => m (Token s)

Parse a character from the first 256 characters of the Unicode character set, corresponding to the ISO 8859-1 (Latin-1) character set.

Single character

valuechar' :: (MonadParsec e s m, Token s ~ Char) => Token s -> m (Token s)

The same as char but case-insensitive. This parser returns the actually parsed character preserving its case.

Example2 expressions
parseTest (char' 'e') "E"'E'parseTest (char' 'e') "G"1:1:unexpected 'G'expecting 'E' or 'e'

Sequence of characters