{-# LANGUAGE Safe #-}
module Data.Char.Number.Roman (
RomanLiteral(I, II, III, IV, V, VI, VII, VIII, IX, X, XI, XII, L, C, D, M)
, RomanStyle(Additive, Subtractive)
, toLiterals
, romanLiteral, romanLiteral'
, romanNumeral, romanNumeral', romanNumeralCase
, romanNumber, romanNumber', romanNumberCase
) where
import Data.Bits((.|.))
import Data.Char(chr)
import Data.Char.Core(UnicodeCharacter(toUnicodeChar, fromUnicodeChar, fromUnicodeChar'), UnicodeText, LetterCase, Ligate, ligateF, mapFromEnum, mapToEnum, mapToEnumSafe, splitLetterCase)
import Data.Default(Default(def))
import Data.Text(Text, cons, empty)
import Test.QuickCheck.Arbitrary(Arbitrary(arbitrary), arbitraryBoundedEnum)
data RomanStyle
= Additive
| Subtractive
deriving (RomanStyle
RomanStyle -> RomanStyle -> Bounded RomanStyle
forall a. a -> a -> Bounded a
maxBound :: RomanStyle
$cmaxBound :: RomanStyle
minBound :: RomanStyle
$cminBound :: RomanStyle
Bounded, Int -> RomanStyle
RomanStyle -> Int
RomanStyle -> [RomanStyle]
RomanStyle -> RomanStyle
RomanStyle -> RomanStyle -> [RomanStyle]
RomanStyle -> RomanStyle -> RomanStyle -> [RomanStyle]
(RomanStyle -> RomanStyle)
-> (RomanStyle -> RomanStyle)
-> (Int -> RomanStyle)
-> (RomanStyle -> Int)
-> (RomanStyle -> [RomanStyle])
-> (RomanStyle -> RomanStyle -> [RomanStyle])
-> (RomanStyle -> RomanStyle -> [RomanStyle])
-> (RomanStyle -> RomanStyle -> RomanStyle -> [RomanStyle])
-> Enum RomanStyle
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: RomanStyle -> RomanStyle -> RomanStyle -> [RomanStyle]
$cenumFromThenTo :: RomanStyle -> RomanStyle -> RomanStyle -> [RomanStyle]
enumFromTo :: RomanStyle -> RomanStyle -> [RomanStyle]
$cenumFromTo :: RomanStyle -> RomanStyle -> [RomanStyle]
enumFromThen :: RomanStyle -> RomanStyle -> [RomanStyle]
$cenumFromThen :: RomanStyle -> RomanStyle -> [RomanStyle]
enumFrom :: RomanStyle -> [RomanStyle]
$cenumFrom :: RomanStyle -> [RomanStyle]
fromEnum :: RomanStyle -> Int
$cfromEnum :: RomanStyle -> Int
toEnum :: Int -> RomanStyle
$ctoEnum :: Int -> RomanStyle
pred :: RomanStyle -> RomanStyle
$cpred :: RomanStyle -> RomanStyle
succ :: RomanStyle -> RomanStyle
$csucc :: RomanStyle -> RomanStyle
Enum, RomanStyle -> RomanStyle -> Bool
(RomanStyle -> RomanStyle -> Bool)
-> (RomanStyle -> RomanStyle -> Bool) -> Eq RomanStyle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RomanStyle -> RomanStyle -> Bool
$c/= :: RomanStyle -> RomanStyle -> Bool
== :: RomanStyle -> RomanStyle -> Bool
$c== :: RomanStyle -> RomanStyle -> Bool
Eq, Int -> RomanStyle -> ShowS
[RomanStyle] -> ShowS
RomanStyle -> String
(Int -> RomanStyle -> ShowS)
-> (RomanStyle -> String)
-> ([RomanStyle] -> ShowS)
-> Show RomanStyle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RomanStyle] -> ShowS
$cshowList :: [RomanStyle] -> ShowS
show :: RomanStyle -> String
$cshow :: RomanStyle -> String
showsPrec :: Int -> RomanStyle -> ShowS
$cshowsPrec :: Int -> RomanStyle -> ShowS
Show, ReadPrec [RomanStyle]
ReadPrec RomanStyle
Int -> ReadS RomanStyle
ReadS [RomanStyle]
(Int -> ReadS RomanStyle)
-> ReadS [RomanStyle]
-> ReadPrec RomanStyle
-> ReadPrec [RomanStyle]
-> Read RomanStyle
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RomanStyle]
$creadListPrec :: ReadPrec [RomanStyle]
readPrec :: ReadPrec RomanStyle
$creadPrec :: ReadPrec RomanStyle
readList :: ReadS [RomanStyle]
$creadList :: ReadS [RomanStyle]
readsPrec :: Int -> ReadS RomanStyle
$creadsPrec :: Int -> ReadS RomanStyle
Read)
instance Arbitrary RomanStyle where
arbitrary :: Gen RomanStyle
arbitrary = Gen RomanStyle
forall a. (Bounded a, Enum a) => Gen a
arbitraryBoundedEnum
instance Arbitrary RomanLiteral where
arbitrary :: Gen RomanLiteral
arbitrary = Gen RomanLiteral
forall a. (Bounded a, Enum a) => Gen a
arbitraryBoundedEnum
instance Default RomanStyle where
def :: RomanStyle
def = RomanStyle
Subtractive
instance UnicodeCharacter RomanLiteral where
toUnicodeChar :: RomanLiteral -> Char
toUnicodeChar = Int -> RomanLiteral -> Char
forall a. Enum a => Int -> a -> Char
mapFromEnum Int
_romanUppercaseOffset
fromUnicodeChar :: Char -> Maybe RomanLiteral
fromUnicodeChar = Int -> Char -> Maybe RomanLiteral
forall a. (Bounded a, Enum a) => Int -> Char -> Maybe a
mapToEnumSafe Int
_romanUppercaseOffset
fromUnicodeChar' :: Char -> RomanLiteral
fromUnicodeChar' = Int -> Char -> RomanLiteral
forall a. Enum a => Int -> Char -> a
mapToEnum Int
_romanUppercaseOffset
instance UnicodeText RomanLiteral
data RomanLiteral
= I
| II
| III
| IV
| V
| VI
| VII
| VIII
| IX
| X
| XI
| XII
| L
| C
| D
| M
deriving (RomanLiteral
RomanLiteral -> RomanLiteral -> Bounded RomanLiteral
forall a. a -> a -> Bounded a
maxBound :: RomanLiteral
$cmaxBound :: RomanLiteral
minBound :: RomanLiteral
$cminBound :: RomanLiteral
Bounded, Int -> RomanLiteral
RomanLiteral -> Int
RomanLiteral -> [RomanLiteral]
RomanLiteral -> RomanLiteral
RomanLiteral -> RomanLiteral -> [RomanLiteral]
RomanLiteral -> RomanLiteral -> RomanLiteral -> [RomanLiteral]
(RomanLiteral -> RomanLiteral)
-> (RomanLiteral -> RomanLiteral)
-> (Int -> RomanLiteral)
-> (RomanLiteral -> Int)
-> (RomanLiteral -> [RomanLiteral])
-> (RomanLiteral -> RomanLiteral -> [RomanLiteral])
-> (RomanLiteral -> RomanLiteral -> [RomanLiteral])
-> (RomanLiteral -> RomanLiteral -> RomanLiteral -> [RomanLiteral])
-> Enum RomanLiteral
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: RomanLiteral -> RomanLiteral -> RomanLiteral -> [RomanLiteral]
$cenumFromThenTo :: RomanLiteral -> RomanLiteral -> RomanLiteral -> [RomanLiteral]
enumFromTo :: RomanLiteral -> RomanLiteral -> [RomanLiteral]
$cenumFromTo :: RomanLiteral -> RomanLiteral -> [RomanLiteral]
enumFromThen :: RomanLiteral -> RomanLiteral -> [RomanLiteral]
$cenumFromThen :: RomanLiteral -> RomanLiteral -> [RomanLiteral]
enumFrom :: RomanLiteral -> [RomanLiteral]
$cenumFrom :: RomanLiteral -> [RomanLiteral]
fromEnum :: RomanLiteral -> Int
$cfromEnum :: RomanLiteral -> Int
toEnum :: Int -> RomanLiteral
$ctoEnum :: Int -> RomanLiteral
pred :: RomanLiteral -> RomanLiteral
$cpred :: RomanLiteral -> RomanLiteral
succ :: RomanLiteral -> RomanLiteral
$csucc :: RomanLiteral -> RomanLiteral
Enum, RomanLiteral -> RomanLiteral -> Bool
(RomanLiteral -> RomanLiteral -> Bool)
-> (RomanLiteral -> RomanLiteral -> Bool) -> Eq RomanLiteral
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RomanLiteral -> RomanLiteral -> Bool
$c/= :: RomanLiteral -> RomanLiteral -> Bool
== :: RomanLiteral -> RomanLiteral -> Bool
$c== :: RomanLiteral -> RomanLiteral -> Bool
Eq, Int -> RomanLiteral -> ShowS
[RomanLiteral] -> ShowS
RomanLiteral -> String
(Int -> RomanLiteral -> ShowS)
-> (RomanLiteral -> String)
-> ([RomanLiteral] -> ShowS)
-> Show RomanLiteral
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RomanLiteral] -> ShowS
$cshowList :: [RomanLiteral] -> ShowS
show :: RomanLiteral -> String
$cshow :: RomanLiteral -> String
showsPrec :: Int -> RomanLiteral -> ShowS
$cshowsPrec :: Int -> RomanLiteral -> ShowS
Show, ReadPrec [RomanLiteral]
ReadPrec RomanLiteral
Int -> ReadS RomanLiteral
ReadS [RomanLiteral]
(Int -> ReadS RomanLiteral)
-> ReadS [RomanLiteral]
-> ReadPrec RomanLiteral
-> ReadPrec [RomanLiteral]
-> Read RomanLiteral
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RomanLiteral]
$creadListPrec :: ReadPrec [RomanLiteral]
readPrec :: ReadPrec RomanLiteral
$creadPrec :: ReadPrec RomanLiteral
readList :: ReadS [RomanLiteral]
$creadList :: ReadS [RomanLiteral]
readsPrec :: Int -> ReadS RomanLiteral
$creadsPrec :: Int -> ReadS RomanLiteral
Read)
_literals :: Integral i => RomanStyle -> [(i, [RomanLiteral] -> [RomanLiteral])]
_literals :: RomanStyle -> [(i, [RomanLiteral] -> [RomanLiteral])]
_literals RomanStyle
Additive = [
(i
1000, (RomanLiteral
MRomanLiteral -> [RomanLiteral] -> [RomanLiteral]
forall a. a -> [a] -> [a]
:))
, (i
500, (RomanLiteral
DRomanLiteral -> [RomanLiteral] -> [RomanLiteral]
forall a. a -> [a] -> [a]
:))
, (i
100, (RomanLiteral
CRomanLiteral -> [RomanLiteral] -> [RomanLiteral]
forall a. a -> [a] -> [a]
:))
, (i
50, (RomanLiteral
LRomanLiteral -> [RomanLiteral] -> [RomanLiteral]
forall a. a -> [a] -> [a]
:))
, (i
10, (RomanLiteral
XRomanLiteral -> [RomanLiteral] -> [RomanLiteral]
forall a. a -> [a] -> [a]
:))
, (i
5, (RomanLiteral
VRomanLiteral -> [RomanLiteral] -> [RomanLiteral]
forall a. a -> [a] -> [a]
:))
, (i
1, (RomanLiteral
IRomanLiteral -> [RomanLiteral] -> [RomanLiteral]
forall a. a -> [a] -> [a]
:))
]
_literals RomanStyle
Subtractive = [
(i
1000, (RomanLiteral
MRomanLiteral -> [RomanLiteral] -> [RomanLiteral]
forall a. a -> [a] -> [a]
:))
, (i
900, ([RomanLiteral
C,RomanLiteral
M][RomanLiteral] -> [RomanLiteral] -> [RomanLiteral]
forall a. [a] -> [a] -> [a]
++))
, (i
500, (RomanLiteral
DRomanLiteral -> [RomanLiteral] -> [RomanLiteral]
forall a. a -> [a] -> [a]
:))
, (i
400, ([RomanLiteral
C,RomanLiteral
D][RomanLiteral] -> [RomanLiteral] -> [RomanLiteral]
forall a. [a] -> [a] -> [a]
++))
, (i
100, (RomanLiteral
CRomanLiteral -> [RomanLiteral] -> [RomanLiteral]
forall a. a -> [a] -> [a]
:))
, (i
90, ([RomanLiteral
X,RomanLiteral
C][RomanLiteral] -> [RomanLiteral] -> [RomanLiteral]
forall a. [a] -> [a] -> [a]
++))
, (i
50, (RomanLiteral
LRomanLiteral -> [RomanLiteral] -> [RomanLiteral]
forall a. a -> [a] -> [a]
:))
, (i
40, ([RomanLiteral
X,RomanLiteral
L][RomanLiteral] -> [RomanLiteral] -> [RomanLiteral]
forall a. [a] -> [a] -> [a]
++))
, (i
10, (RomanLiteral
XRomanLiteral -> [RomanLiteral] -> [RomanLiteral]
forall a. a -> [a] -> [a]
:))
, (i
9, ([RomanLiteral
I,RomanLiteral
X][RomanLiteral] -> [RomanLiteral] -> [RomanLiteral]
forall a. [a] -> [a] -> [a]
++))
, (i
5, (RomanLiteral
VRomanLiteral -> [RomanLiteral] -> [RomanLiteral]
forall a. a -> [a] -> [a]
:))
, (i
4, ([RomanLiteral
I,RomanLiteral
V][RomanLiteral] -> [RomanLiteral] -> [RomanLiteral]
forall a. [a] -> [a] -> [a]
++))
, (i
1, (RomanLiteral
IRomanLiteral -> [RomanLiteral] -> [RomanLiteral]
forall a. a -> [a] -> [a]
:))
]
_ligate :: [RomanLiteral] -> [RomanLiteral]
_ligate :: [RomanLiteral] -> [RomanLiteral]
_ligate [] = []
_ligate (RomanLiteral
r:[RomanLiteral]
rs) = RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
go RomanLiteral
r [RomanLiteral]
rs
where go :: RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
go RomanLiteral
x [] = [RomanLiteral
x]
go RomanLiteral
x (RomanLiteral
y:[RomanLiteral]
ys) = RomanLiteral -> RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
f RomanLiteral
x RomanLiteral
y [RomanLiteral]
ys
f :: RomanLiteral -> RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
f RomanLiteral
I RomanLiteral
I = RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
go RomanLiteral
II
f RomanLiteral
II RomanLiteral
I = RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
skip RomanLiteral
III
f RomanLiteral
I RomanLiteral
V = RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
skip RomanLiteral
IV
f RomanLiteral
V RomanLiteral
I = RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
go RomanLiteral
VI
f RomanLiteral
VI RomanLiteral
I = RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
go RomanLiteral
VII
f RomanLiteral
VII RomanLiteral
I = RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
skip RomanLiteral
VIII
f RomanLiteral
X RomanLiteral
I = RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
go RomanLiteral
XI
f RomanLiteral
I RomanLiteral
X = RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
skip RomanLiteral
IX
f RomanLiteral
XI RomanLiteral
I = RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
go RomanLiteral
XII
f RomanLiteral
x RomanLiteral
y = (RomanLiteral
x RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
forall a. a -> [a] -> [a]
:) ([RomanLiteral] -> [RomanLiteral])
-> ([RomanLiteral] -> [RomanLiteral])
-> [RomanLiteral]
-> [RomanLiteral]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
go RomanLiteral
y
skip :: RomanLiteral -> [RomanLiteral] -> [RomanLiteral]
skip = (([RomanLiteral] -> [RomanLiteral])
-> ([RomanLiteral] -> [RomanLiteral])
-> [RomanLiteral]
-> [RomanLiteral]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [RomanLiteral] -> [RomanLiteral]
_ligate) (([RomanLiteral] -> [RomanLiteral])
-> [RomanLiteral] -> [RomanLiteral])
-> (RomanLiteral -> [RomanLiteral] -> [RomanLiteral])
-> RomanLiteral
-> [RomanLiteral]
-> [RomanLiteral]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:)
toLiterals :: Integral i
=> RomanStyle
-> Ligate
-> i
-> Maybe [RomanLiteral]
toLiterals :: RomanStyle -> Ligate -> i -> Maybe [RomanLiteral]
toLiterals RomanStyle
s Ligate
c i
k
| i
k i -> i -> Bool
forall a. Ord a => a -> a -> Bool
> i
0 = ([RomanLiteral] -> [RomanLiteral])
-> Ligate -> Maybe [RomanLiteral] -> Maybe [RomanLiteral]
forall (f :: * -> *) a.
Functor f =>
(a -> a) -> Ligate -> f a -> f a
ligateF [RomanLiteral] -> [RomanLiteral]
_ligate Ligate
c (i
-> [(i, [RomanLiteral] -> [RomanLiteral])] -> Maybe [RomanLiteral]
forall t a. (Num t, Ord t) => t -> [(t, [a] -> [a])] -> Maybe [a]
go i
k (RomanStyle -> [(i, [RomanLiteral] -> [RomanLiteral])]
forall i.
Integral i =>
RomanStyle -> [(i, [RomanLiteral] -> [RomanLiteral])]
_literals RomanStyle
s))
| Bool
otherwise = Maybe [RomanLiteral]
forall a. Maybe a
Nothing
where go :: t -> [(t, [a] -> [a])] -> Maybe [a]
go t
0 [(t, [a] -> [a])]
_ = [a] -> Maybe [a]
forall a. a -> Maybe a
Just []
go t
_ [] = Maybe [a]
forall a. Maybe a
Nothing
go t
n va :: [(t, [a] -> [a])]
va@((t
m, [a] -> [a]
l):[(t, [a] -> [a])]
vs)
| t
n t -> t -> Bool
forall a. Ord a => a -> a -> Bool
>= t
m = [a] -> [a]
l ([a] -> [a]) -> Maybe [a] -> Maybe [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> t -> [(t, [a] -> [a])] -> Maybe [a]
go (t
nt -> t -> t
forall a. Num a => a -> a -> a
-t
m) [(t, [a] -> [a])]
va
| Bool
otherwise = t -> [(t, [a] -> [a])] -> Maybe [a]
go t
n [(t, [a] -> [a])]
vs
_romanUppercaseOffset :: Int
_romanUppercaseOffset :: Int
_romanUppercaseOffset = Int
0x2160
_romanLowercaseOffset :: Int
_romanLowercaseOffset :: Int
_romanLowercaseOffset = Int
0x2170
_romanLiteral :: Int -> RomanLiteral -> Char
_romanLiteral :: Int -> RomanLiteral -> Char
_romanLiteral = (Int -> Char
chr (Int -> Char) -> (RomanLiteral -> Int) -> RomanLiteral -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) ((RomanLiteral -> Int) -> RomanLiteral -> Char)
-> (Int -> RomanLiteral -> Int) -> Int -> RomanLiteral -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Int -> Int) -> (RomanLiteral -> Int) -> RomanLiteral -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RomanLiteral -> Int
forall a. Enum a => a -> Int
fromEnum) ((Int -> Int) -> RomanLiteral -> Int)
-> (Int -> Int -> Int) -> Int -> RomanLiteral -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Int -> Int
forall a. Bits a => a -> a -> a
(.|.)
romanLiteral
:: RomanLiteral
-> Char
romanLiteral :: RomanLiteral -> Char
romanLiteral = Int -> RomanLiteral -> Char
_romanLiteral Int
_romanUppercaseOffset
romanLiteral'
:: RomanLiteral
-> Char
romanLiteral' :: RomanLiteral -> Char
romanLiteral' = Int -> RomanLiteral -> Char
_romanLiteral Int
_romanLowercaseOffset
_romanNumeral :: (RomanLiteral -> Char) -> [RomanLiteral] -> Text
_romanNumeral :: (RomanLiteral -> Char) -> [RomanLiteral] -> Text
_romanNumeral = ((RomanLiteral -> Text -> Text) -> Text -> [RomanLiteral] -> Text
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
`foldr` Text
empty) ((RomanLiteral -> Text -> Text) -> [RomanLiteral] -> Text)
-> ((RomanLiteral -> Char) -> RomanLiteral -> Text -> Text)
-> (RomanLiteral -> Char)
-> [RomanLiteral]
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Text -> Text
cons (Char -> Text -> Text)
-> (RomanLiteral -> Char) -> RomanLiteral -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
.)
romanNumeral
:: [RomanLiteral]
-> Text
romanNumeral :: [RomanLiteral] -> Text
romanNumeral = (RomanLiteral -> Char) -> [RomanLiteral] -> Text
_romanNumeral RomanLiteral -> Char
romanLiteral
romanNumeral'
:: [RomanLiteral]
-> Text
romanNumeral' :: [RomanLiteral] -> Text
romanNumeral' = (RomanLiteral -> Char) -> [RomanLiteral] -> Text
_romanNumeral RomanLiteral -> Char
romanLiteral'
romanNumeralCase
:: LetterCase
-> [RomanLiteral]
-> Text
romanNumeralCase :: LetterCase -> [RomanLiteral] -> Text
romanNumeralCase = ([RomanLiteral] -> Text)
-> ([RomanLiteral] -> Text) -> LetterCase -> [RomanLiteral] -> Text
forall a. a -> a -> LetterCase -> a
splitLetterCase [RomanLiteral] -> Text
romanNumeral [RomanLiteral] -> Text
romanNumeral'
_romanNumber :: Integral i => ([RomanLiteral] -> a) -> RomanStyle -> Ligate -> i -> Maybe a
_romanNumber :: ([RomanLiteral] -> a) -> RomanStyle -> Ligate -> i -> Maybe a
_romanNumber [RomanLiteral] -> a
f RomanStyle
r Ligate
c = ([RomanLiteral] -> a) -> Maybe [RomanLiteral] -> Maybe a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [RomanLiteral] -> a
f (Maybe [RomanLiteral] -> Maybe a)
-> (i -> Maybe [RomanLiteral]) -> i -> Maybe a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RomanStyle -> Ligate -> i -> Maybe [RomanLiteral]
forall i.
Integral i =>
RomanStyle -> Ligate -> i -> Maybe [RomanLiteral]
toLiterals RomanStyle
r Ligate
c
romanNumber :: Integral i
=> RomanStyle
-> Ligate
-> i
-> Maybe Text
romanNumber :: RomanStyle -> Ligate -> i -> Maybe Text
romanNumber = ([RomanLiteral] -> Text) -> RomanStyle -> Ligate -> i -> Maybe Text
forall i a.
Integral i =>
([RomanLiteral] -> a) -> RomanStyle -> Ligate -> i -> Maybe a
_romanNumber [RomanLiteral] -> Text
romanNumeral
romanNumber' :: Integral i
=> RomanStyle
-> Ligate
-> i
-> Maybe Text
romanNumber' :: RomanStyle -> Ligate -> i -> Maybe Text
romanNumber' = ([RomanLiteral] -> Text) -> RomanStyle -> Ligate -> i -> Maybe Text
forall i a.
Integral i =>
([RomanLiteral] -> a) -> RomanStyle -> Ligate -> i -> Maybe a
_romanNumber [RomanLiteral] -> Text
romanNumeral'
romanNumberCase :: Integral i
=> LetterCase
-> RomanStyle
-> Ligate
-> i
-> Maybe Text
romanNumberCase :: LetterCase -> RomanStyle -> Ligate -> i -> Maybe Text
romanNumberCase = (RomanStyle -> Ligate -> i -> Maybe Text)
-> (RomanStyle -> Ligate -> i -> Maybe Text)
-> LetterCase
-> RomanStyle
-> Ligate
-> i
-> Maybe Text
forall a. a -> a -> LetterCase -> a
splitLetterCase RomanStyle -> Ligate -> i -> Maybe Text
forall i. Integral i => RomanStyle -> Ligate -> i -> Maybe Text
romanNumber RomanStyle -> Ligate -> i -> Maybe Text
forall i. Integral i => RomanStyle -> Ligate -> i -> Maybe Text
romanNumber'