alphachar-0.0.1: A character between a-z

Safe HaskellNone
LanguageHaskell2010

Data.Char.Alpha

Contents

Synopsis

Upper-case

parseAlphaUpper :: (Monad f, CharParsing f) => f AlphaUpper Source #

Parse an upper-case alpha character.

>>> parse parseAlphaUpper "parseAlphaUpper" "A"
Right (AlphaUpper 'A')
>>> parse parseAlphaUpper "parseAlphaUpper" "Abc"
Right (AlphaUpper 'A')
>>> isn't _Right (parse parseAlphaUpper "parseAlphaUpper" "a")
True
>>> isn't _Right (parse parseAlphaUpper "parseAlphaUpper" "")
True
>>> isn't _Right (parse parseAlphaUpper "parseAlphaUpper" "0")
True

Lower-case

parseAlphaLower :: (Monad f, CharParsing f) => f AlphaLower Source #

Parse a lower-case alpha character.

>>> parse parseAlphaLower "parseAlphaLower" "a"
Right (AlphaLower 'a')
>>> parse parseAlphaLower "parseAlphaLower" "aBC"
Right (AlphaLower 'a')
>>> isn't _Right (parse parseAlphaLower "parseAlphaLower" "B")
True
>>> isn't _Right (parse parseAlphaLower "parseAlphaLower" "")
True
>>> isn't _Right (parse parseAlphaLower "parseAlphaLower" "0")
True

Any case

class HasAlpha c where Source #

Minimal complete definition

alpha

Methods

alpha :: Lens' c Alpha Source #

parseAlpha :: (Monad f, CharParsing f) => f Alpha Source #

Parse an upper-case or lower-case character.

>>> parse parseAlpha "parseAlpha" "a"
Right (LowerAlpha (AlphaLower 'a'))
>>> parse parseAlpha "parseAlpha" "aBC"
Right (LowerAlpha (AlphaLower 'a'))
>>> parse parseAlpha "parseAlpha" "A"
Right (UpperAlpha (AlphaUpper 'A'))
>>> parse parseAlpha "parseAlpha" "Abc"
Right (UpperAlpha (AlphaUpper 'A'))
>>> isn't _Right (parse parseAlpha "parseAlpha" "0")
True

Accessory

upperlower :: Iso' AlphaUpper AlphaLower Source #

Isomorphism from upper to lower.

>>> (upperlower #) <$> ('a' ^? _AlphaLower)
Just (AlphaUpper 'A')
>>> (upperlower #) <$> ('A' ^? _AlphaLower)
Nothing
>>> (upperlower #) <$> ('3' ^? _AlphaLower)
Nothing

lowerupper :: Iso' AlphaLower AlphaUpper Source #

Isomorphism from lower to upper.

>>> (lowerupper #) <$> ('A' ^? _AlphaUpper)
Just (AlphaLower 'a')
>>> (lowerupper #) <$> ('a' ^? _AlphaUpper)
Nothing
>>> (lowerupper #) <$> ('3' ^? _AlphaUpper)
Nothing