| Copyright | (C) 2026 - Eitan Chatav |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | Eitan Chatav <eitan.chatav@gmail.com> |
| Stability | provisional |
| Portability | non-portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Control.Lens.Grammar.Token
Contents
Description
Synopsis
- class Categorized token => Tokenized token p | p -> token where
- anyToken :: p
- token :: token -> p
- oneOf :: Foldable f => f token -> p
- notOneOf :: Foldable f => f token -> p
- asIn :: Categorize token -> p
- notAsIn :: Categorize token -> p
- satisfy :: (Tokenized a (p a a), Choice p, Cochoice p) => (a -> Bool) -> p a a
- tokens :: (Foldable f, Tokenized a (p a a), Monoidal p, Choice p, AsEmpty s, Cons s s a a) => f a -> p s s
- class (Ord token, Ord (Categorize token), Enum (Categorize token)) => Categorized token where
- type Categorize token
- categorize :: token -> Categorize token
- data GeneralCategory
- = UppercaseLetter
- | LowercaseLetter
- | TitlecaseLetter
- | ModifierLetter
- | OtherLetter
- | NonSpacingMark
- | SpacingCombiningMark
- | EnclosingMark
- | DecimalNumber
- | LetterNumber
- | OtherNumber
- | ConnectorPunctuation
- | DashPunctuation
- | OpenPunctuation
- | ClosePunctuation
- | InitialQuote
- | FinalQuote
- | OtherPunctuation
- | MathSymbol
- | CurrencySymbol
- | ModifierSymbol
- | OtherSymbol
- | Space
- | LineSeparator
- | ParagraphSeparator
- | Control
- | Format
- | Surrogate
- | PrivateUse
- | NotAssigned
Tokenized
class Categorized token => Tokenized token p | p -> token where Source #
Tokenized combinators for constructing lexical tokens.
Minimal complete definition
Methods
Any single token.
A single specified token.
oneOf :: Foldable f => f token -> p Source #
A single token which is oneOf a set.
notOneOf :: Foldable f => f token -> p Source #
A single token which is notOneOf a set.
asIn :: Categorize token -> p Source #
A single token which is asIn a category.
notAsIn :: Categorize token -> p Source #
A single token which is notAsIn a category.
Instances
satisfy :: (Tokenized a (p a a), Choice p, Cochoice p) => (a -> Bool) -> p a a Source #
A single token that satisfies a predicate.
tokens :: (Foldable f, Tokenized a (p a a), Monoidal p, Choice p, AsEmpty s, Cons s s a a) => f a -> p s s Source #
A specified stream of tokens.
Categorized
class (Ord token, Ord (Categorize token), Enum (Categorize token)) => Categorized token where Source #
Categorized provides a type family Categorize
and a function to categorize tokens into disjoint categories.
>>>:kind! Categorize CharCategorize Char :: * = GeneralCategory
>>>categorize 'a'LowercaseLetter
Minimal complete definition
Nothing
Methods
categorize :: token -> Categorize token Source #
default categorize :: Categorize token ~ () => token -> Categorize token Source #
Instances
| Categorized Word8 Source # | |
Defined in Control.Lens.Grammar.Token Associated Types type Categorize Word8 Source # Methods categorize :: Word8 -> Categorize Word8 Source # | |
| Categorized () Source # | |
Defined in Control.Lens.Grammar.Token Associated Types type Categorize () Source # Methods categorize :: () -> Categorize () Source # | |
| Categorized Char Source # | |
Defined in Control.Lens.Grammar.Token Associated Types type Categorize Char Source # Methods categorize :: Char -> Categorize Char Source # | |
data GeneralCategory #
Unicode General Categories (column 2 of the UnicodeData table) in the order they are listed in the Unicode standard (the Unicode Character Database, in particular).
Examples
Basic usage:
>>>:t OtherLetterOtherLetter :: GeneralCategory
Eq instance:
>>>UppercaseLetter == UppercaseLetterTrue>>>UppercaseLetter == LowercaseLetterFalse
Ord instance:
>>>NonSpacingMark <= MathSymbolTrue
Enum instance:
>>>enumFromTo ModifierLetter SpacingCombiningMark[ModifierLetter,OtherLetter,NonSpacingMark,SpacingCombiningMark]
Read instance:
>>>read "DashPunctuation" :: GeneralCategoryDashPunctuation>>>read "17" :: GeneralCategory*** Exception: Prelude.read: no parse
Show instance:
>>>show EnclosingMark"EnclosingMark"
Bounded instance:
>>>minBound :: GeneralCategoryUppercaseLetter>>>maxBound :: GeneralCategoryNotAssigned
Ix instance:
>>>import Data.Ix ( index )>>>index (OtherLetter,Control) FinalQuote12>>>index (OtherLetter,Control) Format*** Exception: Error in array index
Constructors
| UppercaseLetter | Lu: Letter, Uppercase |
| LowercaseLetter | Ll: Letter, Lowercase |
| TitlecaseLetter | Lt: Letter, Titlecase |
| ModifierLetter | Lm: Letter, Modifier |
| OtherLetter | Lo: Letter, Other |
| NonSpacingMark | Mn: Mark, Non-Spacing |
| SpacingCombiningMark | Mc: Mark, Spacing Combining |
| EnclosingMark | Me: Mark, Enclosing |
| DecimalNumber | Nd: Number, Decimal |
| LetterNumber | Nl: Number, Letter |
| OtherNumber | No: Number, Other |
| ConnectorPunctuation | Pc: Punctuation, Connector |
| DashPunctuation | Pd: Punctuation, Dash |
| OpenPunctuation | Ps: Punctuation, Open |
| ClosePunctuation | Pe: Punctuation, Close |
| InitialQuote | Pi: Punctuation, Initial quote |
| FinalQuote | Pf: Punctuation, Final quote |
| OtherPunctuation | Po: Punctuation, Other |
| MathSymbol | Sm: Symbol, Math |
| CurrencySymbol | Sc: Symbol, Currency |
| ModifierSymbol | Sk: Symbol, Modifier |
| OtherSymbol | So: Symbol, Other |
| Space | Zs: Separator, Space |
| LineSeparator | Zl: Separator, Line |
| ParagraphSeparator | Zp: Separator, Paragraph |
| Control | Cc: Other, Control |
| Format | Cf: Other, Format |
| Surrogate | Cs: Other, Surrogate |
| PrivateUse | Co: Other, Private Use |
| NotAssigned | Cn: Other, Not Assigned |