module Data.D10.Char
(
D10 (..)
, d10
, d10list
, d10Exp
, d10ListExp
, d10Pat
, d10ListPat
, d10Char
, charD10Maybe
, charD10Either
, charD10Fail
, d10Str
, strD10Maybe
, strD10Either
, strD10Fail
, strD10ListMaybe
, strD10ListEither
, strD10ListFail
, d10Nat
, natD10Maybe
, natD10Either
, natD10Fail
, natMod10
, d10Integer
, integerD10Maybe
, integerD10Either
, integerD10Fail
, integerMod10
, d10Int
, intD10Maybe
, intD10Either
, intD10Fail
, intMod10
, d10Num
, integralD10Maybe
, integralD10Either
, integralD10Fail
, integralMod10
, (+), (-), (*)
) where
import Data.D10.Predicate
import Control.Monad ((>=>))
import Control.Monad.Fail (MonadFail (fail))
import Data.Char (chr, ord)
import Data.Monoid (Endo (..))
import Numeric.Natural (Natural)
import Prelude hiding (fail, (+), (-), (*))
import qualified Prelude as P
import Language.Haskell.TH.Lib (litP, charL)
import Language.Haskell.TH.Quote (QuasiQuoter (..))
import Language.Haskell.TH.Syntax (Exp (..), Lift, Pat (..), Q)
newtype D10 =
D10_Unsafe Char
deriving (D10 -> D10 -> Bool
(D10 -> D10 -> Bool) -> (D10 -> D10 -> Bool) -> Eq D10
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: D10 -> D10 -> Bool
$c/= :: D10 -> D10 -> Bool
== :: D10 -> D10 -> Bool
$c== :: D10 -> D10 -> Bool
Eq, Eq D10
Eq D10
-> (D10 -> D10 -> Ordering)
-> (D10 -> D10 -> Bool)
-> (D10 -> D10 -> Bool)
-> (D10 -> D10 -> Bool)
-> (D10 -> D10 -> Bool)
-> (D10 -> D10 -> D10)
-> (D10 -> D10 -> D10)
-> Ord D10
D10 -> D10 -> Bool
D10 -> D10 -> Ordering
D10 -> D10 -> D10
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: D10 -> D10 -> D10
$cmin :: D10 -> D10 -> D10
max :: D10 -> D10 -> D10
$cmax :: D10 -> D10 -> D10
>= :: D10 -> D10 -> Bool
$c>= :: D10 -> D10 -> Bool
> :: D10 -> D10 -> Bool
$c> :: D10 -> D10 -> Bool
<= :: D10 -> D10 -> Bool
$c<= :: D10 -> D10 -> Bool
< :: D10 -> D10 -> Bool
$c< :: D10 -> D10 -> Bool
compare :: D10 -> D10 -> Ordering
$ccompare :: D10 -> D10 -> Ordering
$cp1Ord :: Eq D10
Ord, D10 -> Q Exp
D10 -> Q (TExp D10)
(D10 -> Q Exp) -> (D10 -> Q (TExp D10)) -> Lift D10
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: D10 -> Q (TExp D10)
$cliftTyped :: D10 -> Q (TExp D10)
lift :: D10 -> Q Exp
$clift :: D10 -> Q Exp
Lift)
instance Bounded D10
where
minBound :: D10
minBound = Char -> D10
D10_Unsafe Char
'0'
maxBound :: D10
maxBound = Char -> D10
D10_Unsafe Char
'9'
instance Enum D10
where
fromEnum :: D10 -> Int
fromEnum :: D10 -> Int
fromEnum = D10 -> Int
d10Int
toEnum :: Int -> D10
toEnum :: Int -> D10
toEnum = ([Char] -> D10) -> (D10 -> D10) -> Either [Char] D10 -> D10
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either [Char] -> D10
forall a. HasCallStack => [Char] -> a
error D10 -> D10
forall a. a -> a
id (Either [Char] D10 -> D10)
-> (Int -> Either [Char] D10) -> Int -> D10
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Either [Char] D10
intD10Either
enumFrom :: D10 -> [D10]
enumFrom :: D10 -> [D10]
enumFrom D10
x = D10 -> D10 -> [D10]
forall a. Enum a => a -> a -> [a]
enumFromTo D10
x D10
forall a. Bounded a => a
maxBound
enumFromThen :: D10 -> D10 -> [D10]
enumFromThen :: D10 -> D10 -> [D10]
enumFromThen D10
x D10
y = D10 -> D10 -> D10 -> [D10]
forall a. Enum a => a -> a -> a -> [a]
enumFromThenTo D10
x D10
y D10
bound
where
bound :: D10
bound | D10 -> Int
forall a. Enum a => a -> Int
fromEnum D10
y Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= D10 -> Int
forall a. Enum a => a -> Int
fromEnum D10
x = D10
forall a. Bounded a => a
maxBound
| Bool
otherwise = D10
forall a. Bounded a => a
minBound
succ :: D10 -> D10
succ :: D10 -> D10
succ (D10_Unsafe Char
'9') = [Char] -> D10
forall a. HasCallStack => [Char] -> a
error [Char]
"D10 overflow"
succ (D10_Unsafe Char
x) = Char -> D10
D10_Unsafe (Char -> Char
forall a. Enum a => a -> a
succ Char
x)
pred :: D10 -> D10
pred :: D10 -> D10
pred (D10_Unsafe Char
'0') = [Char] -> D10
forall a. HasCallStack => [Char] -> a
error [Char]
"D10 underflow"
pred (D10_Unsafe Char
x) = Char -> D10
D10_Unsafe (Char -> Char
forall a. Enum a => a -> a
pred Char
x)
instance Show D10 where
showsPrec :: Int -> D10 -> ShowS
showsPrec Int
_ D10
x = [Char] -> ShowS
showString [Char]
"[d10|" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. D10 -> ShowS
showsChar D10
x ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> ShowS
showString [Char]
"|]"
showList :: [D10] -> ShowS
showList [D10]
xs = [Char] -> ShowS
showString [Char]
"[d10list|" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [D10] -> ShowS
showsStr [D10]
xs ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> ShowS
showString [Char]
"|]"
showsChar :: D10 -> ShowS
showsChar :: D10 -> ShowS
showsChar (D10_Unsafe Char
x) = Char -> ShowS
showChar Char
x
showsStr :: [D10] -> ShowS
showsStr :: [D10] -> ShowS
showsStr = Endo [Char] -> ShowS
forall a. Endo a -> a -> a
appEndo (Endo [Char] -> ShowS) -> ([D10] -> Endo [Char]) -> [D10] -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (D10 -> Endo [Char]) -> [D10] -> Endo [Char]
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (ShowS -> Endo [Char]
forall a. (a -> a) -> Endo a
Endo (ShowS -> Endo [Char]) -> (D10 -> ShowS) -> D10 -> Endo [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. D10 -> ShowS
showsChar)
d10Char :: D10 -> Char
d10Char :: D10 -> Char
d10Char (D10_Unsafe Char
x) = Char
x
d10Str :: D10 -> String
d10Str :: D10 -> [Char]
d10Str (D10_Unsafe Char
x) = [Char
x]
d10Nat :: D10 -> Natural
d10Nat :: D10 -> Natural
d10Nat (D10_Unsafe Char
x) = Int -> Natural
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Char -> Int
ord Char
x Int -> Int -> Int
forall a. Num a => a -> a -> a
P.- Char -> Int
ord Char
'0')
d10Integer :: D10 -> Integer
d10Integer :: D10 -> Integer
d10Integer (D10_Unsafe Char
x) = Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Char -> Int
ord Char
x Int -> Int -> Int
forall a. Num a => a -> a -> a
P.- Char -> Int
ord Char
'0')
d10Int :: D10 -> Int
d10Int :: D10 -> Int
d10Int (D10_Unsafe Char
x) = Char -> Int
ord Char
x Int -> Int -> Int
forall a. Num a => a -> a -> a
P.- Char -> Int
ord Char
'0'
d10Num :: Num a => D10 -> a
d10Num :: D10 -> a
d10Num (D10_Unsafe Char
x) = Int -> a
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Char -> Int
ord Char
x Int -> Int -> Int
forall a. Num a => a -> a -> a
P.- Char -> Int
ord Char
'0')
natMod10 :: Natural -> D10
natMod10 :: Natural -> D10
natMod10 Natural
x = Char -> D10
D10_Unsafe (Int -> Char
chr (Char -> Int
ord Char
'0' Int -> Int -> Int
forall a. Num a => a -> a -> a
P.+ Natural -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Natural
x Natural -> Natural -> Natural
forall a. Integral a => a -> a -> a
`mod` Natural
10)))
integerMod10 :: Integer -> D10
integerMod10 :: Integer -> D10
integerMod10 Integer
x = Char -> D10
D10_Unsafe (Int -> Char
chr (Char -> Int
ord Char
'0' Int -> Int -> Int
forall a. Num a => a -> a -> a
P.+ Integer -> Int
forall a. Num a => Integer -> a
fromInteger (Integer
x Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
`mod` Integer
10)))
intMod10 :: Int -> D10
intMod10 :: Int -> D10
intMod10 Int
x = Char -> D10
D10_Unsafe (Int -> Char
chr (Char -> Int
ord Char
'0' Int -> Int -> Int
forall a. Num a => a -> a -> a
P.+ (Int
x Int -> Int -> Int
forall a. Integral a => a -> a -> a
`mod` Int
10)))
integralMod10 :: Integral a => a -> D10
integralMod10 :: a -> D10
integralMod10 a
x = Char -> D10
D10_Unsafe (Int -> Char
chr (Char -> Int
ord Char
'0' Int -> Int -> Int
forall a. Num a => a -> a -> a
P.+ a -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (a
x a -> a -> a
forall a. Integral a => a -> a -> a
`mod` a
10)))
charD10Maybe :: Char -> Maybe D10
charD10Maybe :: Char -> Maybe D10
charD10Maybe Char
x
| Char -> Bool
isD10Char Char
x = D10 -> Maybe D10
forall a. a -> Maybe a
Just (Char -> D10
D10_Unsafe Char
x)
| Bool
otherwise = Maybe D10
forall a. Maybe a
Nothing
strD10Maybe :: String -> Maybe D10
strD10Maybe :: [Char] -> Maybe D10
strD10Maybe [Char
x] = Char -> Maybe D10
charD10Maybe Char
x
strD10Maybe [Char]
_ = Maybe D10
forall a. Maybe a
Nothing
strD10ListMaybe :: String -> Maybe [D10]
strD10ListMaybe :: [Char] -> Maybe [D10]
strD10ListMaybe = (Char -> Maybe D10) -> [Char] -> Maybe [D10]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Char -> Maybe D10
charD10Maybe
natD10Maybe :: Natural -> Maybe D10
natD10Maybe :: Natural -> Maybe D10
natD10Maybe Natural
x
| Natural -> Bool
isD10Nat Natural
x = D10 -> Maybe D10
forall a. a -> Maybe a
Just (Char -> D10
D10_Unsafe (Int -> Char
chr (Natural -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
x Int -> Int -> Int
forall a. Num a => a -> a -> a
P.+ Char -> Int
ord Char
'0')))
| Bool
otherwise = Maybe D10
forall a. Maybe a
Nothing
integerD10Maybe :: Integer -> Maybe D10
integerD10Maybe :: Integer -> Maybe D10
integerD10Maybe Integer
x
| Integer -> Bool
isD10Integer Integer
x = D10 -> Maybe D10
forall a. a -> Maybe a
Just (Char -> D10
D10_Unsafe (Int -> Char
chr (Integer -> Int
forall a. Num a => Integer -> a
fromInteger Integer
x Int -> Int -> Int
forall a. Num a => a -> a -> a
P.+ Char -> Int
ord Char
'0')))
| Bool
otherwise = Maybe D10
forall a. Maybe a
Nothing
intD10Maybe :: Int -> Maybe D10
intD10Maybe :: Int -> Maybe D10
intD10Maybe Int
x
| Int -> Bool
isD10Int Int
x = D10 -> Maybe D10
forall a. a -> Maybe a
Just (Char -> D10
D10_Unsafe (Int -> Char
chr (Int
x Int -> Int -> Int
forall a. Num a => a -> a -> a
P.+ Char -> Int
ord Char
'0')))
| Bool
otherwise = Maybe D10
forall a. Maybe a
Nothing
integralD10Maybe :: Integral a => a -> Maybe D10
integralD10Maybe :: a -> Maybe D10
integralD10Maybe a
x = Integer -> Maybe D10
integerD10Maybe (a -> Integer
forall a. Integral a => a -> Integer
toInteger a
x)
charD10Either :: Char -> Either String D10
charD10Either :: Char -> Either [Char] D10
charD10Either Char
x
| Char -> Bool
isD10Char Char
x = D10 -> Either [Char] D10
forall a b. b -> Either a b
Right (Char -> D10
D10_Unsafe Char
x)
| Bool
otherwise = [Char] -> Either [Char] D10
forall a b. a -> Either a b
Left [Char]
"d10 must be between 0 and 9"
strD10Either :: String -> Either String D10
strD10Either :: [Char] -> Either [Char] D10
strD10Either [Char
x] = Char -> Either [Char] D10
charD10Either Char
x
strD10Either [Char]
_ = [Char] -> Either [Char] D10
forall a b. a -> Either a b
Left [Char]
"d10 must be a single character"
strD10ListEither :: String -> Either String [D10]
strD10ListEither :: [Char] -> Either [Char] [D10]
strD10ListEither = (Char -> Either [Char] D10) -> [Char] -> Either [Char] [D10]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Char -> Either [Char] D10
charD10Either
natD10Either :: Natural -> Either String D10
natD10Either :: Natural -> Either [Char] D10
natD10Either Natural
x =
case (Natural -> Maybe D10
natD10Maybe Natural
x) of
Just D10
y -> D10 -> Either [Char] D10
forall a b. b -> Either a b
Right D10
y
Maybe D10
Nothing -> [Char] -> Either [Char] D10
forall a b. a -> Either a b
Left [Char]
"d10 must be less than 10"
integerD10Either :: Integer -> Either String D10
integerD10Either :: Integer -> Either [Char] D10
integerD10Either Integer
x =
case (Integer -> Maybe D10
integerD10Maybe Integer
x) of
Just D10
y -> D10 -> Either [Char] D10
forall a b. b -> Either a b
Right D10
y
Maybe D10
Nothing -> [Char] -> Either [Char] D10
forall a b. a -> Either a b
Left [Char]
"d10 must be between 0 and 9"
intD10Either :: Int -> Either String D10
intD10Either :: Int -> Either [Char] D10
intD10Either Int
x =
case (Int -> Maybe D10
intD10Maybe Int
x) of
Just D10
y -> D10 -> Either [Char] D10
forall a b. b -> Either a b
Right D10
y
Maybe D10
Nothing -> [Char] -> Either [Char] D10
forall a b. a -> Either a b
Left [Char]
"d10 must be between 0 and 9"
integralD10Either :: Integral a => a -> Either String D10
integralD10Either :: a -> Either [Char] D10
integralD10Either a
x = Integer -> Either [Char] D10
integerD10Either (a -> Integer
forall a. Integral a => a -> Integer
toInteger a
x)
charD10Fail :: MonadFail m => Char -> m D10
charD10Fail :: Char -> m D10
charD10Fail Char
x
| Char -> Bool
isD10Char Char
x = D10 -> m D10
forall (m :: * -> *) a. Monad m => a -> m a
return (Char -> D10
D10_Unsafe Char
x)
| Bool
otherwise = [Char] -> m D10
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
"d10 must be between 0 and 9"
strD10Fail :: MonadFail m => String -> m D10
strD10Fail :: [Char] -> m D10
strD10Fail [Char
x] = Char -> m D10
forall (m :: * -> *). MonadFail m => Char -> m D10
charD10Fail Char
x
strD10Fail [Char]
_ = [Char] -> m D10
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
"d10 must be a single character"
strD10ListFail :: MonadFail m => String -> m [D10]
strD10ListFail :: [Char] -> m [D10]
strD10ListFail = (Char -> m D10) -> [Char] -> m [D10]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Char -> m D10
forall (m :: * -> *). MonadFail m => Char -> m D10
charD10Fail
natD10Fail :: MonadFail m => Natural -> m D10
natD10Fail :: Natural -> m D10
natD10Fail Natural
x =
case (Natural -> Maybe D10
natD10Maybe Natural
x) of
Just D10
y -> D10 -> m D10
forall (m :: * -> *) a. Monad m => a -> m a
return D10
y
Maybe D10
Nothing -> [Char] -> m D10
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
"d10 must be less than 10"
integerD10Fail :: MonadFail m => Integer -> m D10
integerD10Fail :: Integer -> m D10
integerD10Fail Integer
x =
case (Integer -> Maybe D10
integerD10Maybe Integer
x) of
Just D10
y -> D10 -> m D10
forall (m :: * -> *) a. Monad m => a -> m a
return D10
y
Maybe D10
Nothing -> [Char] -> m D10
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
"d10 must be between 0 and 9"
intD10Fail :: MonadFail m => Int -> m D10
intD10Fail :: Int -> m D10
intD10Fail Int
x =
case (Int -> Maybe D10
intD10Maybe Int
x) of
Just D10
y -> D10 -> m D10
forall (m :: * -> *) a. Monad m => a -> m a
return D10
y
Maybe D10
Nothing -> [Char] -> m D10
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
"d10 must be between 0 and 9"
integralD10Fail :: (Integral a, MonadFail m) => a -> m D10
integralD10Fail :: a -> m D10
integralD10Fail a
x = Integer -> m D10
forall (m :: * -> *). MonadFail m => Integer -> m D10
integerD10Fail (a -> Integer
forall a. Integral a => a -> Integer
toInteger a
x)
d10Exp :: Integer -> Q Exp
d10Exp :: Integer -> Q Exp
d10Exp = Integer -> Q D10
forall (m :: * -> *). MonadFail m => Integer -> m D10
integerD10Fail (Integer -> Q D10) -> (D10 -> Q Exp) -> Integer -> Q Exp
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> D10 -> Q Exp
d10Exp'
d10Exp' :: D10 -> Q Exp
d10Exp' :: D10 -> Q Exp
d10Exp' D10
x = [| x |]
d10ListExp :: String -> Q Exp
d10ListExp :: [Char] -> Q Exp
d10ListExp = [Char] -> Q [D10]
forall (m :: * -> *). MonadFail m => [Char] -> m [D10]
strD10ListFail ([Char] -> Q [D10]) -> ([D10] -> Q Exp) -> [Char] -> Q Exp
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> [D10] -> Q Exp
d10ListExp'
d10ListExp' :: [D10] -> Q Exp
d10ListExp' :: [D10] -> Q Exp
d10ListExp' [D10]
xs = [| xs |]
d10Pat :: Integer -> Q Pat
d10Pat :: Integer -> Q Pat
d10Pat = Integer -> Q D10
forall (m :: * -> *). MonadFail m => Integer -> m D10
integerD10Fail (Integer -> Q D10) -> (D10 -> Q Pat) -> Integer -> Q Pat
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> D10 -> Q Pat
d10Pat'
d10Pat' :: D10 -> Q Pat
d10Pat' :: D10 -> Q Pat
d10Pat' (D10_Unsafe Char
x) = [p| D10_Unsafe $(litP $ charL x) |]
d10ListPat :: String -> Q Pat
d10ListPat :: [Char] -> Q Pat
d10ListPat = [Char] -> Q [D10]
forall (m :: * -> *). MonadFail m => [Char] -> m [D10]
strD10ListFail ([Char] -> Q [D10]) -> ([D10] -> Q Pat) -> [Char] -> Q Pat
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (D10 -> Q Pat -> Q Pat) -> Q Pat -> [D10] -> Q Pat
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\D10
x Q Pat
p -> [p| $(d10Pat' x) : $(p) |]) [p| [] |]
d10 :: QuasiQuoter
d10 :: QuasiQuoter
d10 = QuasiQuoter :: ([Char] -> Q Exp)
-> ([Char] -> Q Pat)
-> ([Char] -> Q Type)
-> ([Char] -> Q [Dec])
-> QuasiQuoter
QuasiQuoter
{ quoteExp :: [Char] -> Q Exp
quoteExp = [Char] -> Q D10
forall (m :: * -> *). MonadFail m => [Char] -> m D10
strD10Fail ([Char] -> Q D10) -> (D10 -> Q Exp) -> [Char] -> Q Exp
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> D10 -> Q Exp
d10Exp'
, quotePat :: [Char] -> Q Pat
quotePat = [Char] -> Q D10
forall (m :: * -> *). MonadFail m => [Char] -> m D10
strD10Fail ([Char] -> Q D10) -> (D10 -> Q Pat) -> [Char] -> Q Pat
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> D10 -> Q Pat
d10Pat'
, quoteType :: [Char] -> Q Type
quoteType = \[Char]
_ -> [Char] -> Q Type
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
"d10 cannot be used in a type context"
, quoteDec :: [Char] -> Q [Dec]
quoteDec = \[Char]
_ -> [Char] -> Q [Dec]
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
"d10 cannot be used in a declaration context"
}
d10list :: QuasiQuoter
d10list :: QuasiQuoter
d10list = QuasiQuoter :: ([Char] -> Q Exp)
-> ([Char] -> Q Pat)
-> ([Char] -> Q Type)
-> ([Char] -> Q [Dec])
-> QuasiQuoter
QuasiQuoter
{ quoteExp :: [Char] -> Q Exp
quoteExp = [Char] -> Q [D10]
forall (m :: * -> *). MonadFail m => [Char] -> m [D10]
strD10ListFail ([Char] -> Q [D10]) -> ([D10] -> Q Exp) -> [Char] -> Q Exp
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> [D10] -> Q Exp
d10ListExp'
, quotePat :: [Char] -> Q Pat
quotePat = [Char] -> Q Pat
d10ListPat
, quoteType :: [Char] -> Q Type
quoteType = \[Char]
_ -> [Char] -> Q Type
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
"d10list cannot be used in a type context"
, quoteDec :: [Char] -> Q [Dec]
quoteDec = \[Char]
_ -> [Char] -> Q [Dec]
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
"d10list cannot be used in a declaration context"
}
(+) :: D10 -> D10 -> D10
D10
x + :: D10 -> D10 -> D10
+ D10
y = Int -> D10
intMod10 (D10 -> Int
d10Int D10
x Int -> Int -> Int
forall a. Num a => a -> a -> a
P.+ D10 -> Int
d10Int D10
y)
(-) :: D10 -> D10 -> D10
D10
x - :: D10 -> D10 -> D10
- D10
y = Int -> D10
intMod10 (D10 -> Int
d10Int D10
x Int -> Int -> Int
forall a. Num a => a -> a -> a
P.- D10 -> Int
d10Int D10
y)
(*) :: D10 -> D10 -> D10
D10
x * :: D10 -> D10 -> D10
* D10
y = Int -> D10
intMod10 (D10 -> Int
d10Int D10
x Int -> Int -> Int
forall a. Num a => a -> a -> a
P.* D10 -> Int
d10Int D10
y)