d10
Digits 0-9
https://github.com/typeclasses/d10
Version on this page: | 0.3.0.1 |
LTS Haskell 21.25: | 1.0.1.3 |
Stackage Nightly 2023-06-21: | 1.0.1.2 |
Latest on Hackage: | 1.0.1.3 |
d10-0.3.0.1@sha256:1dba511771ec9a36d5c6a4604e624a674b4f1633c6024e890260599bc98348f2,5006
Module documentation for 0.3.0.1
- Data
d10
Data types representing the digits zero through nine.
Modules
Each of the following modules defines a different type named
D10
, all of which are different representations of the same
concept:
Data.D10.Char
- Defines aD10
type as a newtype forChar
, where the values are restricted to characters between'0'
and'9'
.Data.D10.Num
- Defines aD10
type as a newtype for any type with an instance of theNum
class, where the values are restricted to numbers betweenfromInteger 0
andfromInteger 9
.Data.D10.Safe
- Defines aD10
type asD0 | D1 | D2 | ... | D9
.
Other modules:
Data.D10.Predicate
- Functions to test whether values of various types represent digits in the range 0 to 9.
Quasi-quoters
Each module that defines a D10
type also defines quasi-quoters
for it. With the QuasiQuotes
GHC extension enabled, a single
digit like 7 can be written as [d10|7|]
, and a list of digits
like [4,5,6] can be written as [d10|456|]
. For Data.D10.Char
and Data.D10.Num
, the quasi-quoters are an important feature,
because the D10
types defined in these modules have unsafe
constructors, and the quasi-quoters provide compile-time assurance
that we never construct a D10
that represents a value outside
the range 0 to 9. For Data.D10.Safe
, the quasi-quoter is
offered merely as a possible convenience, allowing you to write
[d10|456789|]
in place of the somewhat longer expression
[D4,D5,D6,D7,D8,D9]
.
Changes
v0.1.0.0
- Initial release
v0.1.0.1
- Improve error messages when quasi-quoters are used in a non-expression context
v0.1.1.0
- Add functions for generating Template Haskell expressions to be spliced, as alternatives to using the quasi-quoters
v0.2.0.0
- Add Template Haskell splice patterns
d10Pat
andd10ListPat
- Define
quotePat
for the quasi-quotersd10
andd10list
, so they can now be used with pattern matching - Add
Integral a
constraint tod10
andd10list
in theData.D10.Num
module, because this is needed for the definition ofquotePat
.
v0.2.0.1
- Add
CHANGELOG.md
to package distribution
v0.2.1.0
- Add functions mod-10 arithmetic functions:
(+)
,(-)
,(*)
v0.2.1.2
- Support GHC 8.8
v0.2.1.4
- Support GHC 8.10
v0.2.1.6
- Support
doctest-0.17
v0.3
In module Data.D10.Char
:
- Removed
isD10Str
(seeData.D10.Predicate
) - Type of
d10Exp
changed fromIntegral a => a -> Q Exp
toInteger -> Q Exp
- Type of
d10Pat
changed fromD10 -> Q Pat
toInteger -> Q Pat
- Type of
d10ListPat
changed from[D10] -> Q Pat
toString -> Q Pat
In module Data.D10.Num
:
- Removed
isD10Str
(seeData.D10.Predicate
) - Type of
d10Exp
changed from(Integral b, Lift a, Num a) => b -> Q Exp
toInteger -> Q Exp
- Type of
d10ListExp
changed from(Lift a, Num a) => String -> Q Exp
toString -> Q Exp
- Type of
d10Pat
changed fromIntegral a => D10 a -> Q Pat
toInteger -> Q Pat
- Type of
d10ListPat
changed fromIntegral a => [D10 a] -> Q Pat
toString -> Q Pat
- Type of
d10
changed from(Lift a, Integral a) => QuasiQuoter
toQuasiQuoter
- Type of
d10list
changed from(Lift a, Integral a) => QuasiQuoter
toQuasiQuoter
- Although type variables no longer appear in the various Template Haskell functions, the expressions and patterns they generate are polymorphic.
In module Data.D10.Safe
:
- The
D10
type now has instances of theData
andGeneric
. - Type of
d10ListPat
changed from[D10] -> Q Pat
toString -> Q Pat
- Removed
d10Exp
,d10Pat
, andd10
Other changes:
doctest
test dependency has been removed, andhedgehog
dependency has been added instead
v0.3.0.1
- Support GHC 9.0, base 4.15, template-haskell 2.17