digit-0.1.0: A data-type representing digits 0-9 and other combinations

Safe HaskellNone

Data.Digit.Digit

Contents

Description

A data type with ten nullary constructors [0-9] and combinators.

Synopsis

Data type

data Digit Source

A data type with ten nullary constructors.

Destructors

foldDigitSource

Arguments

:: a

Zero.

-> a

One.

-> a

Two.

-> a

Three.

-> a

Four.

-> a

Five.

-> a

Six.

-> a

Seven.

-> a

Eight.

-> a

Nine.

-> Digit

The digit to fold.

-> a 

Catamorphism for Digit.

foldDigit x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 d0 == x0
foldDigit x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 d1 == x1
foldDigit x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 d2 == x2
foldDigit x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 d3 == x3
foldDigit x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 d4 == x4
foldDigit x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 d5 == x5
foldDigit x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 d6 == x6
foldDigit x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 d7 == x7
foldDigit x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 d8 == x8
foldDigit x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 d9 == x9

Prisms

digit :: Prism' Int DigitSource

A prism for using Int as Digit.

>>> 5 ^? digit
Just 5
>>> 0 ^? digit
Just 0
>>> 9 ^? digit
Just 9
>>> 10 ^? digit
Nothing
>>> (-5) ^? digit
Nothing

digitC :: Prism' Char DigitSource

A prism for using Char as Digit.

>>> '5' ^? digitC
Just 5
>>> '0' ^? digitC
Just 0
>>> '9' ^? digitC
Just 9
>>> 'a' ^? digitC
Nothing
>>> '@' ^? digitC
Nothing