Safe Haskell | Trustworthy |
---|---|
Language | GHC2021 |
Expressions
d10Exp :: Integer -> Q Exp Source #
Produces an expression of type
that can be used
in a Template Haskell splice.D10
a
>>>
d10Nat $(d10Exp 5)
5
>>>
d10Nat $(d10Exp 12)
... ... d10 must be between 0 and 9 ...
You may also be interested in d10
, a quasi-quoter which
does something similar.
d10ListExp :: String -> Q Exp Source #
Produces an expression of type [
that can be used
in a Template Haskell splice.D10
a]
>>>
d10Nat <$> $(d10ListExp "")
[]
>>>
d10Nat <$> $(d10ListExp "5")
[5]
>>>
d10Nat <$> $(d10ListExp "58")
[5,8]
>>>
d10Nat <$> $(d10ListExp "a")
... ... d10 must be between 0 and 9 ...
You may also be interested in d10list
, a quasi-quoter which
does something similar.
Patterns
d10Pat :: Integer -> Q Pat Source #
Produces a pattern that can be used in a splice
to match a particular
value.D10
a
>>>
:{
case (charD10Maybe '5') of Just $(d10Pat 4) -> "A" Just $(d10Pat 5) -> "B" _ -> "C">>>
:}
"B"
You may wish to use the d10
quasi-quoter instead.
d10ListPat :: String -> Q Pat Source #
Produces a pattern that can be used in a splice
to match a particular list of
values.D10
a
>>>
:{
case (strD10ListMaybe "56") of Just $(d10ListPat "42") -> "A" Just $(d10ListPat "56") -> "B" _ -> "C">>>
:}
"B"
You may wish to use the d10list
quasi-quoter instead.