-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Digits 0-9 -- -- Data types representing the digits zero through nine. -- --
-- >>> d10Char [d10|7|] -- '7' --d10Char :: Integral a => D10 a -> Char -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or produce Nothing otherwise. -- --
-- isD10Char x = isJust (charD10Maybe x) ---- -- charD10Fail is a more general version of this function. -- --
-- >>> charD10Maybe '5' -- Just [d10|5|] ---- --
-- >>> charD10Maybe 'a' -- Nothing --charD10Maybe :: Num a => Char -> Maybe (D10 a) -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or Left with an error message -- otherwise. -- --
-- >>> charD10Either '5' -- Right [d10|5|] ---- --
-- >>> charD10Either 'a' -- Left "d10 must be between 0 and 9" --charD10Either :: Num a => Char -> Either String (D10 a) -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or fail with an error message -- otherwise. -- -- charD10Maybe is a specialized version of this function. -- --
-- >>> charD10Fail '5' :: IO (D10 Int) -- [d10|5|] ---- --
-- >>> charD10Fail 'a' :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) --charD10Fail :: (Num a, MonadFail m) => Char -> m (D10 a) -- | Convert a D10 to a String. -- --
-- d10Str x = [d10Char x] ---- --
-- >>> d10Str [d10|7|] -- "7" --d10Str :: Integral a => D10 a -> String -- | Convert a String to a D10 if it consists of exactly one -- character and that character is within the range '0' to -- '9', or produce Nothing otherwise. -- --
-- isD10Str x = isJust (strD10Maybe x) ---- -- strD10Fail is a more general version of this function. -- --
-- >>> strD10Maybe "5" -- Just [d10|5|] ---- --
-- >>> strD10Maybe "a" -- Nothing ---- --
-- >>> strD10Maybe "58" -- Nothing --strD10Maybe :: Num a => String -> Maybe (D10 a) -- | Convert a String to a D10 if it consists of a single -- character and that character is within the range '0' to -- '9', or Left with an error message otherwise. -- --
-- >>> strD10Either "5" -- Right [d10|5|] ---- --
-- >>> strD10Either "a" -- Left "d10 must be between 0 and 9" ---- --
-- >>> strD10Either "58" -- Left "d10 must be a single character" --strD10Either :: Num a => String -> Either String (D10 a) -- | Convert a String to a D10 if it consists of a single -- character and that character is within the range '0' to -- '9', or fail with an error message otherwise. -- -- strD10Maybe is a specialized version of this function. -- --
-- >>> strD10Fail "5" :: IO (D10 Int) -- [d10|5|] ---- --
-- >>> strD10Fail "a" :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> strD10Fail "58" :: IO (D10 Int) -- *** Exception: user error (d10 must be a single character) --strD10Fail :: (Num a, MonadFail m) => String -> m (D10 a) -- | Convert a String to a list of D10 if all of the -- characters in the string are within the range '0' to -- '9', or produce Nothing otherwise. -- --
-- isD10ListStr x = isJust (strD10ListMaybe x) ---- -- strD10ListFail is a more general version of this function. -- --
-- >>> strD10ListMaybe "5" -- Just [d10list|5|] ---- --
-- >>> strD10ListMaybe "a" -- Nothing ---- --
-- >>> strD10ListMaybe "58" -- Just [d10list|58|] --strD10ListMaybe :: Num a => String -> Maybe [D10 a] -- | Convert a String to a D10 if all of the characters in -- the string fall within the range '0' to '9', or -- Left with an error message otherwise. -- --
-- >>> strD10ListEither "5" -- Right [d10list|5|] ---- --
-- >>> strD10ListEither "a" -- Left "d10 must be between 0 and 9" ---- --
-- >>> strD10ListEither "58" -- Right [d10list|58|] --strD10ListEither :: Num a => String -> Either String [D10 a] -- | Convert a String to a D10 if all of the characters in -- the string fall within the range '0' to '9', or -- fail with an error message otherwise. -- -- strD10ListMaybe is a specialized version of this function. -- --
-- >>> strD10ListFail "5" :: IO [D10 Int] -- [d10list|5|] ---- --
-- >>> strD10ListFail "a" :: IO [D10 Int] -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> strD10ListFail "58" :: IO [D10 Int] -- [d10list|58|] --strD10ListFail :: (Num a, MonadFail m) => String -> m [D10 a] -- | Convert a D10 to a Natural. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Nat [d10|7|] -- 7 --d10Nat :: Integral a => D10 a -> Natural -- | Convert a Natural to a D10 if it is less than 10, or -- produce Nothing otherwise. -- --
-- isD10Nat x = isJust (natD10Maybe x) ---- -- integralD10Maybe, natD10Fail, and integralD10Fail -- are more general versions of this function. -- --
-- >>> natD10Maybe 5 -- Just [d10|5|] ---- --
-- >>> natD10Maybe 12 -- Nothing --natD10Maybe :: Num a => Natural -> Maybe (D10 a) -- | Convert a Natural to a D10 if it is less than 10, or -- Left with an error message otherwise. -- --
-- >>> natD10Either 5 -- Right [d10|5|] ---- --
-- >>> natD10Either 12 -- Left "d10 must be less than 10" --natD10Either :: Num a => Natural -> Either String (D10 a) -- | Convert a Natural to a D10 if it is less than 10, or -- fail with an error message otherwise. -- -- natD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> natD10Fail 5 :: IO (D10 Int) -- [d10|5|] ---- --
-- >>> natD10Fail 12 :: IO (D10 Int) -- *** Exception: user error (d10 must be less than 10) --natD10Fail :: (Num a, MonadFail m) => Natural -> m (D10 a) -- | The D10 which is uniquely congruent modulo 10 to the given -- Natural. -- -- integralMod10 is a more general version of this function. -- --
-- >>> natMod10 56 :: D10 Int -- [d10|6|] --natMod10 :: Num a => Natural -> D10 a -- | Convert a D10 to an Integer. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Integer [d10|7|] -- 7 --d10Integer :: Integral a => D10 a -> Integer -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or produce Nothing otherwise. -- --
-- isD10Integer x = isJust (integerD10Maybe x) ---- -- integralD10Maybe, integerD10Fail, and -- integralD10Fail are more general versions of this function. -- --
-- >>> integerD10Maybe 5 -- Just [d10|5|] ---- --
-- >>> integerD10Maybe 12 -- Nothing ---- --
-- >>> integerD10Maybe (-5) -- Nothing --integerD10Maybe :: Num a => Integer -> Maybe (D10 a) -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or Left with an error message otherwise. -- --
-- >>> integerD10Either 5 -- Right [d10|5|] ---- --
-- >>> integerD10Either 12 -- Left "d10 must be between 0 and 9" ---- --
-- >>> integerD10Either (-5) -- Left "d10 must be between 0 and 9" --integerD10Either :: Num a => Integer -> Either String (D10 a) -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or fail with an error message otherwise. -- -- integerD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> integerD10Fail 5 :: IO (D10 Int) -- [d10|5|] ---- --
-- >>> integerD10Fail 12 :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> integerD10Fail (-5) :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) --integerD10Fail :: (Num a, MonadFail m) => Integer -> m (D10 a) -- | The D10 which is uniquely congruent modulo 10 to the given -- Integer. -- -- integralMod10 is a more general version of this function. -- --
-- >>> integerMod10 56 :: D10 Int -- [d10|6|] ---- --
-- >>> integerMod10 (-56) :: D10 Int -- [d10|4|] --integerMod10 :: Num a => Integer -> D10 a -- | Convert a D10 to an Int. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Int [d10|7|] -- 7 --d10Int :: Integral a => D10 a -> Int -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or produce Nothing otherwise. -- --
-- isD10Int x = isJust (intD10Maybe x) ---- -- integralD10Maybe, intD10Fail, and integralD10Fail -- are more general versions of this function. -- --
-- >>> intD10Maybe 5 -- Just [d10|5|] ---- --
-- >>> intD10Maybe 12 -- Nothing ---- --
-- >>> intD10Maybe (-5) -- Nothing --intD10Maybe :: Num a => Int -> Maybe (D10 a) -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or Left with an error message otherwise. -- --
-- >>> intD10Either 5 -- Right [d10|5|] ---- --
-- >>> intD10Either 12 -- Left "d10 must be between 0 and 9" ---- --
-- >>> intD10Either (-5) -- Left "d10 must be between 0 and 9" --intD10Either :: Num a => Int -> Either String (D10 a) -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or fail with an error message otherwise. -- -- intD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> intD10Fail 5 :: IO (D10 Int) -- [d10|5|] ---- --
-- >>> intD10Fail 12 :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> intD10Fail (-5) :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) --intD10Fail :: (Num a, MonadFail m) => Int -> m (D10 a) -- | The D10 which is uniquely congruent modulo 10 to the given -- Int. -- -- integralMod10 is a more general version of this function. -- --
-- >>> intMod10 56 :: D10 Int -- [d10|6|] ---- --
-- >>> intMod10 (-56) :: D10 Int -- [d10|4|] --intMod10 :: Num a => Int -> D10 a -- | Convert a D10 to any kind of number with a Num instance. -- -- Specialized versions of this function include d10Nat, -- d10Integer, and d10Int. -- --
-- >>> d10Num [d10|7|] :: Integer -- 7 --d10Num :: (Integral b, Num a) => D10 b -> a -- | Construct a D10 from any kind of number with an Integral -- instance, or produce Nothing if the number falls outside the -- range 0 to 9. -- --
-- isD10Integral x = isJust (integralD10Maybe x) ---- -- Specialized versions of this function include natD10Maybe, -- integerD10Maybe, and intD10Maybe. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> integralD10Maybe (5 :: Integer) -- Just [d10|5|] ---- --
-- >>> integralD10Maybe (12 :: Integer) -- Nothing ---- --
-- >>> integralD10Maybe ((-5) :: Integer) -- Nothing --integralD10Maybe :: (Num b, Integral a) => a -> Maybe (D10 b) -- | Convert a number of a type that has an Integral instance to a -- D10 if it falls within the range 0 to 9, or Left with an -- error message otherwise. -- --
-- >>> integralD10Either (5 :: Integer) -- Right [d10|5|] ---- --
-- >>> integralD10Either (12 :: Integer) -- Left "d10 must be between 0 and 9" ---- --
-- >>> integralD10Either ((-5) :: Integer) -- Left "d10 must be between 0 and 9" --integralD10Either :: (Num b, Integral a) => a -> Either String (D10 b) -- | Convert a number of a type that has an Integral instance to a -- D10 if it falls within the range 0 to 9, or fail with an -- error message otherwise. -- -- natD10Maybe, integerD10Maybe, intD10Maybe, -- integralD10Maybe, natD10Fail, integerD10Fail, and -- intD10Fail are all specialized versions of this function. -- --
-- >>> integralD10Fail (5 :: Integer) :: IO (D10 Int) -- [d10|5|] ---- --
-- >>> integralD10Fail (12 :: Integer) :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> integralD10Fail ((-5) :: Integer) :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) --integralD10Fail :: (Num b, Integral a, MonadFail m) => a -> m (D10 b) -- | The D10 which is uniquely congruent modulo 10 to the given -- number (whose type must have an instance of the Integral -- class). -- -- Specialized versions of this function include natMod10, -- integerMod10, and intMod10. -- --
-- >>> integralMod10 (56 :: Integer) :: D10 Int -- [d10|6|] ---- --
-- >>> integralMod10 ((-56) :: Integer) :: D10 Int -- [d10|4|] --integralMod10 :: (Num b, Integral a) => a -> D10 b module D10.Num.Splices -- | Produces an expression of type D10 a that can be used -- in a Template Haskell splice. -- --
-- >>> 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. d10Exp :: Integer -> Q Exp -- | Produces an expression of type [D10 a] that can be -- used in a Template Haskell splice. -- --
-- >>> 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. d10ListExp :: String -> Q Exp -- | Produces a pattern that can be used in a splice to match a particular -- D10 a value. -- --
-- >>> :{
-- case (charD10Maybe '5') of
-- Just $(d10Pat 4) -> "A"
-- Just $(d10Pat 5) -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
-- You may wish to use the d10 quasi-quoter instead.
d10Pat :: Integer -> Q Pat
-- | Produces a pattern that can be used in a splice to match a particular
-- list of D10 a values.
--
--
-- >>> :{
-- case (strD10ListMaybe "56") of
-- Just $(d10ListPat "42") -> "A"
-- Just $(d10ListPat "56") -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
-- You may wish to use the d10list quasi-quoter instead.
d10ListPat :: String -> Q Pat
module D10.Num.Quotes
-- | A single base-10 digit.
--
-- This quasi-quoter, when used as an expression, produces a value of
-- type D10 a.
--
-- -- >>> d10Nat [d10|5|] -- 5 ---- --
-- >>> d10Nat [d10|a|] -- ... -- ... d10 must be between 0 and 9 -- ... ---- --
-- >>> d10Nat [d10|58|] -- ... -- ... d10 must be a single character -- ... ---- -- This quasi-quoter can also be used as a pattern. -- --
-- >>> :{
-- case (charD10Maybe '5') of
-- Just [d10|4|] -> "A"
-- Just [d10|5|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
--
-- >>> :{
-- case (charD10Maybe '5') of
-- Just [d10|x|] -> "A"
-- Just [d10|5|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- ...
-- ... d10 must be between 0 and 9
-- ...
--
d10 :: QuasiQuoter
-- | A list of base-10 digits.
--
-- This quasi-quoter, when used as an expression, produces a value of
-- type [D10 a].
--
-- -- >>> d10Nat <$> [d10list||] -- [] ---- --
-- >>> d10Nat <$> [d10list|5|] -- [5] ---- --
-- >>> d10Nat <$> [d10list|58|] -- [5,8] ---- --
-- >>> d10Nat <$> [d10list|a|] -- ... -- ... d10 must be between 0 and 9 -- ... ---- -- This quasi-quoter can also be used as a pattern. -- --
-- >>> :{
-- case [d10list|56|] of
-- [d10list|41|] -> "A"
-- [d10list|56|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
--
-- >>> :{
-- case [d10list|56|] of
-- [d10list|4x|] -> "A"
-- [d10list|56|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- ...
-- ... d10 must be between 0 and 9
-- ...
--
d10list :: QuasiQuoter
-- | Defines a D10 type as a newtype for any type with an instance
-- of the Num class, where the values are restricted to numbers
-- between fromInteger 0 and fromInteger
-- 9.
--
-- This module provides many functions for constructing D10
-- values, including:
--
-- integerD10Maybe :: Num a => Integer -- -> Maybe (D10 a)
integerMod10 :: Num a => Integer -- -> D10 a
-- >>> d10Nat [d10|5|] -- 5 ---- --
-- >>> d10Nat [d10|a|] -- ... -- ... d10 must be between 0 and 9 -- ... ---- --
-- >>> d10Nat [d10|58|] -- ... -- ... d10 must be a single character -- ... ---- -- This quasi-quoter can also be used as a pattern. -- --
-- >>> :{
-- case (charD10Maybe '5') of
-- Just [d10|4|] -> "A"
-- Just [d10|5|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
--
-- >>> :{
-- case (charD10Maybe '5') of
-- Just [d10|x|] -> "A"
-- Just [d10|5|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- ...
-- ... d10 must be between 0 and 9
-- ...
--
d10 :: QuasiQuoter
-- | A list of base-10 digits.
--
-- This quasi-quoter, when used as an expression, produces a value of
-- type [D10 a].
--
-- -- >>> d10Nat <$> [d10list||] -- [] ---- --
-- >>> d10Nat <$> [d10list|5|] -- [5] ---- --
-- >>> d10Nat <$> [d10list|58|] -- [5,8] ---- --
-- >>> d10Nat <$> [d10list|a|] -- ... -- ... d10 must be between 0 and 9 -- ... ---- -- This quasi-quoter can also be used as a pattern. -- --
-- >>> :{
-- case [d10list|56|] of
-- [d10list|41|] -> "A"
-- [d10list|56|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
--
-- >>> :{
-- case [d10list|56|] of
-- [d10list|4x|] -> "A"
-- [d10list|56|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- ...
-- ... d10 must be between 0 and 9
-- ...
--
d10list :: QuasiQuoter
-- | Produces an expression of type D10 a that can be used
-- in a Template Haskell splice.
--
-- -- >>> 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. d10Exp :: Integer -> Q Exp -- | Produces an expression of type [D10 a] that can be -- used in a Template Haskell splice. -- --
-- >>> 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. d10ListExp :: String -> Q Exp -- | Produces a pattern that can be used in a splice to match a particular -- D10 a value. -- --
-- >>> :{
-- case (charD10Maybe '5') of
-- Just $(d10Pat 4) -> "A"
-- Just $(d10Pat 5) -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
-- You may wish to use the d10 quasi-quoter instead.
d10Pat :: Integer -> Q Pat
-- | Produces a pattern that can be used in a splice to match a particular
-- list of D10 a values.
--
--
-- >>> :{
-- case (strD10ListMaybe "56") of
-- Just $(d10ListPat "42") -> "A"
-- Just $(d10ListPat "56") -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
-- You may wish to use the d10list quasi-quoter instead.
d10ListPat :: String -> Q Pat
-- | Convert a D10 to its underlying Char representation.
--
-- -- >>> d10Char [d10|7|] -- '7' --d10Char :: Integral a => D10 a -> Char -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or produce Nothing otherwise. -- --
-- isD10Char x = isJust (charD10Maybe x) ---- -- charD10Fail is a more general version of this function. -- --
-- >>> charD10Maybe '5' -- Just [d10|5|] ---- --
-- >>> charD10Maybe 'a' -- Nothing --charD10Maybe :: Num a => Char -> Maybe (D10 a) -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or Left with an error message -- otherwise. -- --
-- >>> charD10Either '5' -- Right [d10|5|] ---- --
-- >>> charD10Either 'a' -- Left "d10 must be between 0 and 9" --charD10Either :: Num a => Char -> Either String (D10 a) -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or fail with an error message -- otherwise. -- -- charD10Maybe is a specialized version of this function. -- --
-- >>> charD10Fail '5' :: IO (D10 Int) -- [d10|5|] ---- --
-- >>> charD10Fail 'a' :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) --charD10Fail :: (Num a, MonadFail m) => Char -> m (D10 a) -- | Convert a D10 to a String. -- --
-- d10Str x = [d10Char x] ---- --
-- >>> d10Str [d10|7|] -- "7" --d10Str :: Integral a => D10 a -> String -- | Convert a String to a D10 if it consists of exactly one -- character and that character is within the range '0' to -- '9', or produce Nothing otherwise. -- --
-- isD10Str x = isJust (strD10Maybe x) ---- -- strD10Fail is a more general version of this function. -- --
-- >>> strD10Maybe "5" -- Just [d10|5|] ---- --
-- >>> strD10Maybe "a" -- Nothing ---- --
-- >>> strD10Maybe "58" -- Nothing --strD10Maybe :: Num a => String -> Maybe (D10 a) -- | Convert a String to a D10 if it consists of a single -- character and that character is within the range '0' to -- '9', or Left with an error message otherwise. -- --
-- >>> strD10Either "5" -- Right [d10|5|] ---- --
-- >>> strD10Either "a" -- Left "d10 must be between 0 and 9" ---- --
-- >>> strD10Either "58" -- Left "d10 must be a single character" --strD10Either :: Num a => String -> Either String (D10 a) -- | Convert a String to a D10 if it consists of a single -- character and that character is within the range '0' to -- '9', or fail with an error message otherwise. -- -- strD10Maybe is a specialized version of this function. -- --
-- >>> strD10Fail "5" :: IO (D10 Int) -- [d10|5|] ---- --
-- >>> strD10Fail "a" :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> strD10Fail "58" :: IO (D10 Int) -- *** Exception: user error (d10 must be a single character) --strD10Fail :: (Num a, MonadFail m) => String -> m (D10 a) -- | Convert a String to a list of D10 if all of the -- characters in the string are within the range '0' to -- '9', or produce Nothing otherwise. -- --
-- isD10ListStr x = isJust (strD10ListMaybe x) ---- -- strD10ListFail is a more general version of this function. -- --
-- >>> strD10ListMaybe "5" -- Just [d10list|5|] ---- --
-- >>> strD10ListMaybe "a" -- Nothing ---- --
-- >>> strD10ListMaybe "58" -- Just [d10list|58|] --strD10ListMaybe :: Num a => String -> Maybe [D10 a] -- | Convert a String to a D10 if all of the characters in -- the string fall within the range '0' to '9', or -- Left with an error message otherwise. -- --
-- >>> strD10ListEither "5" -- Right [d10list|5|] ---- --
-- >>> strD10ListEither "a" -- Left "d10 must be between 0 and 9" ---- --
-- >>> strD10ListEither "58" -- Right [d10list|58|] --strD10ListEither :: Num a => String -> Either String [D10 a] -- | Convert a String to a D10 if all of the characters in -- the string fall within the range '0' to '9', or -- fail with an error message otherwise. -- -- strD10ListMaybe is a specialized version of this function. -- --
-- >>> strD10ListFail "5" :: IO [D10 Int] -- [d10list|5|] ---- --
-- >>> strD10ListFail "a" :: IO [D10 Int] -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> strD10ListFail "58" :: IO [D10 Int] -- [d10list|58|] --strD10ListFail :: (Num a, MonadFail m) => String -> m [D10 a] -- | Convert a D10 to a Natural. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Nat [d10|7|] -- 7 --d10Nat :: Integral a => D10 a -> Natural -- | Convert a Natural to a D10 if it is less than 10, or -- produce Nothing otherwise. -- --
-- isD10Nat x = isJust (natD10Maybe x) ---- -- integralD10Maybe, natD10Fail, and integralD10Fail -- are more general versions of this function. -- --
-- >>> natD10Maybe 5 -- Just [d10|5|] ---- --
-- >>> natD10Maybe 12 -- Nothing --natD10Maybe :: Num a => Natural -> Maybe (D10 a) -- | Convert a Natural to a D10 if it is less than 10, or -- Left with an error message otherwise. -- --
-- >>> natD10Either 5 -- Right [d10|5|] ---- --
-- >>> natD10Either 12 -- Left "d10 must be less than 10" --natD10Either :: Num a => Natural -> Either String (D10 a) -- | Convert a Natural to a D10 if it is less than 10, or -- fail with an error message otherwise. -- -- natD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> natD10Fail 5 :: IO (D10 Int) -- [d10|5|] ---- --
-- >>> natD10Fail 12 :: IO (D10 Int) -- *** Exception: user error (d10 must be less than 10) --natD10Fail :: (Num a, MonadFail m) => Natural -> m (D10 a) -- | The D10 which is uniquely congruent modulo 10 to the given -- Natural. -- -- integralMod10 is a more general version of this function. -- --
-- >>> natMod10 56 :: D10 Int -- [d10|6|] --natMod10 :: Num a => Natural -> D10 a -- | Convert a D10 to an Integer. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Integer [d10|7|] -- 7 --d10Integer :: Integral a => D10 a -> Integer -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or produce Nothing otherwise. -- --
-- isD10Integer x = isJust (integerD10Maybe x) ---- -- integralD10Maybe, integerD10Fail, and -- integralD10Fail are more general versions of this function. -- --
-- >>> integerD10Maybe 5 -- Just [d10|5|] ---- --
-- >>> integerD10Maybe 12 -- Nothing ---- --
-- >>> integerD10Maybe (-5) -- Nothing --integerD10Maybe :: Num a => Integer -> Maybe (D10 a) -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or Left with an error message otherwise. -- --
-- >>> integerD10Either 5 -- Right [d10|5|] ---- --
-- >>> integerD10Either 12 -- Left "d10 must be between 0 and 9" ---- --
-- >>> integerD10Either (-5) -- Left "d10 must be between 0 and 9" --integerD10Either :: Num a => Integer -> Either String (D10 a) -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or fail with an error message otherwise. -- -- integerD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> integerD10Fail 5 :: IO (D10 Int) -- [d10|5|] ---- --
-- >>> integerD10Fail 12 :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> integerD10Fail (-5) :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) --integerD10Fail :: (Num a, MonadFail m) => Integer -> m (D10 a) -- | The D10 which is uniquely congruent modulo 10 to the given -- Integer. -- -- integralMod10 is a more general version of this function. -- --
-- >>> integerMod10 56 :: D10 Int -- [d10|6|] ---- --
-- >>> integerMod10 (-56) :: D10 Int -- [d10|4|] --integerMod10 :: Num a => Integer -> D10 a -- | Convert a D10 to an Int. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Int [d10|7|] -- 7 --d10Int :: Integral a => D10 a -> Int -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or produce Nothing otherwise. -- --
-- isD10Int x = isJust (intD10Maybe x) ---- -- integralD10Maybe, intD10Fail, and integralD10Fail -- are more general versions of this function. -- --
-- >>> intD10Maybe 5 -- Just [d10|5|] ---- --
-- >>> intD10Maybe 12 -- Nothing ---- --
-- >>> intD10Maybe (-5) -- Nothing --intD10Maybe :: Num a => Int -> Maybe (D10 a) -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or Left with an error message otherwise. -- --
-- >>> intD10Either 5 -- Right [d10|5|] ---- --
-- >>> intD10Either 12 -- Left "d10 must be between 0 and 9" ---- --
-- >>> intD10Either (-5) -- Left "d10 must be between 0 and 9" --intD10Either :: Num a => Int -> Either String (D10 a) -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or fail with an error message otherwise. -- -- intD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> intD10Fail 5 :: IO (D10 Int) -- [d10|5|] ---- --
-- >>> intD10Fail 12 :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> intD10Fail (-5) :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) --intD10Fail :: (Num a, MonadFail m) => Int -> m (D10 a) -- | The D10 which is uniquely congruent modulo 10 to the given -- Int. -- -- integralMod10 is a more general version of this function. -- --
-- >>> intMod10 56 :: D10 Int -- [d10|6|] ---- --
-- >>> intMod10 (-56) :: D10 Int -- [d10|4|] --intMod10 :: Num a => Int -> D10 a -- | Convert a D10 to any kind of number with a Num instance. -- -- Specialized versions of this function include d10Nat, -- d10Integer, and d10Int. -- --
-- >>> d10Num [d10|7|] :: Integer -- 7 --d10Num :: (Integral b, Num a) => D10 b -> a -- | Construct a D10 from any kind of number with an Integral -- instance, or produce Nothing if the number falls outside the -- range 0 to 9. -- --
-- isD10Integral x = isJust (integralD10Maybe x) ---- -- Specialized versions of this function include natD10Maybe, -- integerD10Maybe, and intD10Maybe. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> integralD10Maybe (5 :: Integer) -- Just [d10|5|] ---- --
-- >>> integralD10Maybe (12 :: Integer) -- Nothing ---- --
-- >>> integralD10Maybe ((-5) :: Integer) -- Nothing --integralD10Maybe :: (Num b, Integral a) => a -> Maybe (D10 b) -- | Convert a number of a type that has an Integral instance to a -- D10 if it falls within the range 0 to 9, or Left with an -- error message otherwise. -- --
-- >>> integralD10Either (5 :: Integer) -- Right [d10|5|] ---- --
-- >>> integralD10Either (12 :: Integer) -- Left "d10 must be between 0 and 9" ---- --
-- >>> integralD10Either ((-5) :: Integer) -- Left "d10 must be between 0 and 9" --integralD10Either :: (Num b, Integral a) => a -> Either String (D10 b) -- | Convert a number of a type that has an Integral instance to a -- D10 if it falls within the range 0 to 9, or fail with an -- error message otherwise. -- -- natD10Maybe, integerD10Maybe, intD10Maybe, -- integralD10Maybe, natD10Fail, integerD10Fail, and -- intD10Fail are all specialized versions of this function. -- --
-- >>> integralD10Fail (5 :: Integer) :: IO (D10 Int) -- [d10|5|] ---- --
-- >>> integralD10Fail (12 :: Integer) :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> integralD10Fail ((-5) :: Integer) :: IO (D10 Int) -- *** Exception: user error (d10 must be between 0 and 9) --integralD10Fail :: (Num b, Integral a, MonadFail m) => a -> m (D10 b) -- | The D10 which is uniquely congruent modulo 10 to the given -- number (whose type must have an instance of the Integral -- class). -- -- Specialized versions of this function include natMod10, -- integerMod10, and intMod10. -- --
-- >>> integralMod10 (56 :: Integer) :: D10 Int -- [d10|6|] ---- --
-- >>> integralMod10 ((-56) :: Integer) :: D10 Int -- [d10|4|] --integralMod10 :: (Num b, Integral a) => a -> D10 b module D10.Num.Arithmetic -- | Addition modulo 10. -- --
-- >>> [d10|2|] + [d10|3|] -- [d10|5|] ---- --
-- >>> [d10|6|] + [d10|7|] -- [d10|3|] --(+) :: Integral a => D10 a -> D10 a -> D10 a -- | Subtraction modulo 10. -- --
-- >>> [d10|7|] - [d10|5|] -- [d10|2|] ---- --
-- >>> [d10|3|] - [d10|7|] -- [d10|6|] --(-) :: Integral a => D10 a -> D10 a -> D10 a -- | Multiplication modulo 10. -- --
-- >>> [d10|2|] * [d10|4|] -- [d10|8|] ---- --
-- >>> [d10|7|] * [d10|8|] -- [d10|6|] --(*) :: Integral a => D10 a -> D10 a -> D10 a module D10.Char.Unsafe -- | A Char value between '0' and '9' newtype D10 -- | The constructor's name include the word "unsafe" as a reminder that -- you should generally avoid using it directly, because it allows -- constructing invalid D10 values. D10_Unsafe :: Char -> D10 instance GHC.Classes.Ord D10.Char.Unsafe.D10 instance GHC.Classes.Eq D10.Char.Unsafe.D10 instance GHC.Enum.Bounded D10.Char.Unsafe.D10 instance GHC.Enum.Enum D10.Char.Unsafe.D10 instance GHC.Show.Show D10.Char.Unsafe.D10 module D10.Char.Type -- | A Char value between '0' and '9' data D10 module D10.Char.Conversions -- | Convert a D10 to its underlying Char representation. -- --
-- >>> d10Char [d10|7|] -- '7' --d10Char :: D10 -> Char -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or produce Nothing otherwise. -- --
-- isD10Char x = isJust (charD10Maybe x) ---- -- charD10Fail is a more general version of this function. -- --
-- >>> charD10Maybe '5' -- Just [d10|5|] ---- --
-- >>> charD10Maybe 'a' -- Nothing --charD10Maybe :: Char -> Maybe D10 -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or Left with an error message -- otherwise. -- --
-- >>> charD10Either '5' -- Right [d10|5|] ---- --
-- >>> charD10Either 'a' -- Left "d10 must be between 0 and 9" --charD10Either :: Char -> Either String D10 -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or fail with an error message -- otherwise. -- -- charD10Maybe is a specialized version of this function. -- --
-- >>> charD10Fail '5' :: IO D10 -- [d10|5|] ---- --
-- >>> charD10Fail 'a' :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --charD10Fail :: MonadFail m => Char -> m D10 -- | Convert a D10 to a String. -- --
-- d10Str x = [d10Char x] ---- --
-- >>> d10Str [d10|7|] -- "7" --d10Str :: D10 -> String -- | Convert a String to a D10 if it consists of exactly one -- character and that character is within the range '0' to -- '9', or produce Nothing otherwise. -- --
-- isD10Str x = isJust (strD10Maybe x) ---- -- strD10Fail is a more general version of this function. -- --
-- >>> strD10Maybe "5" -- Just [d10|5|] ---- --
-- >>> strD10Maybe "a" -- Nothing ---- --
-- >>> strD10Maybe "58" -- Nothing --strD10Maybe :: String -> Maybe D10 -- | Convert a String to a D10 if it consists of a single -- character and that character is within the range '0' to -- '9', or Left with an error message otherwise. -- --
-- >>> strD10Either "5" -- Right [d10|5|] ---- --
-- >>> strD10Either "a" -- Left "d10 must be between 0 and 9" ---- --
-- >>> strD10Either "58" -- Left "d10 must be a single character" --strD10Either :: String -> Either String D10 -- | Convert a String to a D10 if it consists of a single -- character and that character is within the range '0' to -- '9', or fail with an error message otherwise. -- -- strD10Maybe is a specialized version of this function. -- --
-- >>> strD10Fail "5" :: IO D10 -- [d10|5|] ---- --
-- >>> strD10Fail "a" :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> strD10Fail "58" :: IO D10 -- *** Exception: user error (d10 must be a single character) --strD10Fail :: MonadFail m => String -> m D10 -- | Convert a String to a list of D10 if all of the -- characters in the string are within the range '0' to -- '9', or produce Nothing otherwise. -- --
-- isD10ListStr x = isJust (strD10ListMaybe x) ---- -- strD10ListFail is a more general version of this function. -- --
-- >>> strD10ListMaybe "5" -- Just [d10list|5|] ---- --
-- >>> strD10ListMaybe "a" -- Nothing ---- --
-- >>> strD10ListMaybe "58" -- Just [d10list|58|] --strD10ListMaybe :: String -> Maybe [D10] -- | Convert a String to a D10 if all of the characters in -- the string fall within the range '0' to '9', or -- Left with an error message otherwise. -- --
-- >>> strD10ListEither "5" -- Right [d10list|5|] ---- --
-- >>> strD10ListEither "a" -- Left "d10 must be between 0 and 9" ---- --
-- >>> strD10ListEither "58" -- Right [d10list|58|] --strD10ListEither :: String -> Either String [D10] -- | Convert a String to a D10 if all of the characters in -- the string fall within the range '0' to '9', or -- fail with an error message otherwise. -- -- strD10ListMaybe is a specialized version of this function. -- --
-- >>> strD10ListFail "5" :: IO [D10] -- [d10list|5|] ---- --
-- >>> strD10ListFail "a" :: IO [D10] -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> strD10ListFail "58" :: IO [D10] -- [d10list|58|] --strD10ListFail :: MonadFail m => String -> m [D10] -- | Convert a D10 to a Natural. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Nat [d10|7|] -- 7 --d10Nat :: D10 -> Natural -- | Convert a Natural to a D10 if it is less than 10, or -- produce Nothing otherwise. -- --
-- isD10Nat x = isJust (natD10Maybe x) ---- -- integralD10Maybe, natD10Fail, and integralD10Fail -- are more general versions of this function. -- --
-- >>> natD10Maybe 5 -- Just [d10|5|] ---- --
-- >>> natD10Maybe 12 -- Nothing --natD10Maybe :: Natural -> Maybe D10 -- | Convert a Natural to a D10 if it is less than 10, or -- Left with an error message otherwise. -- --
-- >>> natD10Either 5 -- Right [d10|5|] ---- --
-- >>> natD10Either 12 -- Left "d10 must be less than 10" --natD10Either :: Natural -> Either String D10 -- | Convert a Natural to a D10 if it is less than 10, or -- fail with an error message otherwise. -- -- natD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> natD10Fail 5 :: IO D10 -- [d10|5|] ---- --
-- >>> natD10Fail 12 :: IO D10 -- *** Exception: user error (d10 must be less than 10) --natD10Fail :: MonadFail m => Natural -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- Natural. -- -- integralMod10 is a more general version of this function. -- --
-- >>> natMod10 56 -- [d10|6|] --natMod10 :: Natural -> D10 -- | Convert a D10 to an Integer. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Integer [d10|7|] -- 7 --d10Integer :: D10 -> Integer -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or produce Nothing otherwise. -- --
-- isD10Integer x = isJust (integerD10Maybe x) ---- -- integralD10Maybe, integerD10Fail, and -- integralD10Fail are more general versions of this function. -- --
-- >>> integerD10Maybe 5 -- Just [d10|5|] ---- --
-- >>> integerD10Maybe 12 -- Nothing ---- --
-- >>> integerD10Maybe (-5) -- Nothing --integerD10Maybe :: Integer -> Maybe D10 -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or Left with an error message otherwise. -- --
-- >>> integerD10Either 5 -- Right [d10|5|] ---- --
-- >>> integerD10Either 12 -- Left "d10 must be between 0 and 9" ---- --
-- >>> integerD10Either (-5) -- Left "d10 must be between 0 and 9" --integerD10Either :: Integer -> Either String D10 -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or fail with an error message otherwise. -- -- integerD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> integerD10Fail 5 :: IO D10 -- [d10|5|] ---- --
-- >>> integerD10Fail 12 :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> integerD10Fail (-5) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --integerD10Fail :: MonadFail m => Integer -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- Integer. -- -- integralMod10 is a more general version of this function. -- --
-- >>> integerMod10 56 -- [d10|6|] ---- --
-- >>> integerMod10 (-56) -- [d10|4|] --integerMod10 :: Integer -> D10 -- | Convert a D10 to an Int. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Int [d10|7|] -- 7 --d10Int :: D10 -> Int -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or produce Nothing otherwise. -- --
-- isD10Int x = isJust (intD10Maybe x) ---- -- integralD10Maybe, intD10Fail, and integralD10Fail -- are more general versions of this function. -- --
-- >>> intD10Maybe 5 -- Just [d10|5|] ---- --
-- >>> intD10Maybe 12 -- Nothing ---- --
-- >>> intD10Maybe (-5) -- Nothing --intD10Maybe :: Int -> Maybe D10 -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or Left with an error message otherwise. -- --
-- >>> intD10Either 5 -- Right [d10|5|] ---- --
-- >>> intD10Either 12 -- Left "d10 must be between 0 and 9" ---- --
-- >>> intD10Either (-5) -- Left "d10 must be between 0 and 9" --intD10Either :: Int -> Either String D10 -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or fail with an error message otherwise. -- -- intD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> intD10Fail 5 :: IO D10 -- [d10|5|] ---- --
-- >>> intD10Fail 12 :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> intD10Fail (-5) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --intD10Fail :: MonadFail m => Int -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- Int. -- -- integralMod10 is a more general version of this function. -- --
-- >>> intMod10 56 -- [d10|6|] ---- --
-- >>> intMod10 (-56) -- [d10|4|] --intMod10 :: Int -> D10 -- | Convert a D10 to any kind of number with a Num instance. -- -- Specialized versions of this function include d10Nat, -- d10Integer, and d10Int. -- --
-- >>> d10Num [d10|7|] :: Integer -- 7 --d10Num :: Num a => D10 -> a -- | Construct a D10 from any kind of number with an Integral -- instance, or produce Nothing if the number falls outside the -- range 0 to 9. -- --
-- isD10Integral x = isJust (integralD10Maybe x) ---- -- Specialized versions of this function include natD10Maybe, -- integerD10Maybe, and intD10Maybe. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> integralD10Maybe (5 :: Integer) -- Just [d10|5|] ---- --
-- >>> integralD10Maybe (12 :: Integer) -- Nothing ---- --
-- >>> integralD10Maybe ((-5) :: Integer) -- Nothing --integralD10Maybe :: Integral a => a -> Maybe D10 -- | Convert a number of a type that has an Integral instance to a -- D10 if it falls within the range 0 to 9, or Left with an -- error message otherwise. -- --
-- >>> integralD10Either (5 :: Integer) -- Right [d10|5|] ---- --
-- >>> integralD10Either (12 :: Integer) -- Left "d10 must be between 0 and 9" ---- --
-- >>> integralD10Either ((-5) :: Integer) -- Left "d10 must be between 0 and 9" --integralD10Either :: Integral a => a -> Either String D10 -- | Convert a number of a type that has an Integral instance to a -- D10 if it falls within the range 0 to 9, or fail with an -- error message otherwise. -- -- natD10Maybe, integerD10Maybe, intD10Maybe, -- integralD10Maybe, natD10Fail, integerD10Fail, and -- intD10Fail are all specialized versions of this function. -- --
-- >>> integralD10Fail (5 :: Integer) :: IO D10 -- [d10|5|] ---- --
-- >>> integralD10Fail (12 :: Integer) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> integralD10Fail ((-5) :: Integer) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --integralD10Fail :: (Integral a, MonadFail m) => a -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- number (whose type must have an instance of the Integral -- class). -- -- Specialized versions of this function include natMod10, -- integerMod10, and intMod10. -- --
-- >>> integralMod10 (56 :: Integer) -- [d10|6|] ---- --
-- >>> integralMod10 ((-56) :: Integer) -- [d10|4|] --integralMod10 :: Integral a => a -> D10 module D10.Char.Splices -- | Produces an expression of type D10 that can be used in a -- Template Haskell splice. -- --
-- >>> 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. d10Exp :: Integer -> Q Exp -- | Produces an expression of type [D10] that can be used -- in a Template Haskell splice. -- --
-- >>> 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. d10ListExp :: String -> Q Exp -- | Produces a pattern that can be used in a splice to match a particular -- D10 value. -- --
-- >>> :{
-- case (charD10Maybe '5') of
-- Just $(d10Pat 4) -> "A"
-- Just $(d10Pat 5) -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
-- You may wish to use the d10 quasi-quoter instead.
d10Pat :: Integer -> Q Pat
-- | Produces a pattern that can be used in a splice to match a particular
-- list of D10 values.
--
--
-- >>> :{
-- case (strD10ListMaybe "56") of
-- Just $(d10ListPat "42") -> "A"
-- Just $(d10ListPat "56") -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
-- You may wish to use the d10list quasi-quoter instead.
d10ListPat :: String -> Q Pat
module D10.Char.Quotes
-- | A single base-10 digit.
--
-- This quasi-quoter, when used as an expression, produces a value of
-- type D10.
--
-- -- >>> d10Nat [d10|5|] -- 5 ---- --
-- >>> d10Nat [d10|a|] -- ... -- ... d10 must be between 0 and 9 -- ... ---- --
-- >>> d10Nat [d10|58|] -- ... -- ... d10 must be a single character -- ... ---- -- This quasi-quoter can also be used as a pattern. -- --
-- >>> :{
-- case (charD10Maybe '5') of
-- Just [d10|4|] -> "A"
-- Just [d10|5|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
--
-- >>> :{
-- case (charD10Maybe '5') of
-- Just [d10|x|] -> "A"
-- Just [d10|5|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- ...
-- ... d10 must be between 0 and 9
-- ...
--
d10 :: QuasiQuoter
-- | A list of base-10 digits.
--
-- This quasi-quoter, when used as an expression, produces a value of
-- type [D10].
--
-- -- >>> d10Nat <$> [d10list||] -- [] ---- --
-- >>> d10Nat <$> [d10list|5|] -- [5] ---- --
-- >>> d10Nat <$> [d10list|58|] -- [5,8] ---- --
-- >>> d10Nat <$> [d10list|a|] -- ... -- ... d10 must be between 0 and 9 -- ... ---- -- This quasi-quoter can also be used as a pattern. -- --
-- >>> :{
-- case [d10list|56|] of
-- [d10list|41|] -> "A"
-- [d10list|56|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
--
-- >>> :{
-- case [d10list|56|] of
-- [d10list|4x|] -> "A"
-- [d10list|56|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- ...
-- ... d10 must be between 0 and 9
-- ...
--
d10list :: QuasiQuoter
-- | Defines a D10 type as a newtype for Char, where the
-- values are restricted to characters between '0' and
-- '9'.
--
-- This module provides many functions for constructing D10
-- values, including:
--
-- integerD10Maybe :: Integer -> Maybe -- D10
integerMod10 :: Integer -> -- D10
-- >>> d10Nat [d10|5|] -- 5 ---- --
-- >>> d10Nat [d10|a|] -- ... -- ... d10 must be between 0 and 9 -- ... ---- --
-- >>> d10Nat [d10|58|] -- ... -- ... d10 must be a single character -- ... ---- -- This quasi-quoter can also be used as a pattern. -- --
-- >>> :{
-- case (charD10Maybe '5') of
-- Just [d10|4|] -> "A"
-- Just [d10|5|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
--
-- >>> :{
-- case (charD10Maybe '5') of
-- Just [d10|x|] -> "A"
-- Just [d10|5|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- ...
-- ... d10 must be between 0 and 9
-- ...
--
d10 :: QuasiQuoter
-- | A list of base-10 digits.
--
-- This quasi-quoter, when used as an expression, produces a value of
-- type [D10].
--
-- -- >>> d10Nat <$> [d10list||] -- [] ---- --
-- >>> d10Nat <$> [d10list|5|] -- [5] ---- --
-- >>> d10Nat <$> [d10list|58|] -- [5,8] ---- --
-- >>> d10Nat <$> [d10list|a|] -- ... -- ... d10 must be between 0 and 9 -- ... ---- -- This quasi-quoter can also be used as a pattern. -- --
-- >>> :{
-- case [d10list|56|] of
-- [d10list|41|] -> "A"
-- [d10list|56|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
--
-- >>> :{
-- case [d10list|56|] of
-- [d10list|4x|] -> "A"
-- [d10list|56|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- ...
-- ... d10 must be between 0 and 9
-- ...
--
d10list :: QuasiQuoter
-- | Produces an expression of type D10 that can be used in a
-- Template Haskell splice.
--
-- -- >>> 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. d10Exp :: Integer -> Q Exp -- | Produces an expression of type [D10] that can be used -- in a Template Haskell splice. -- --
-- >>> 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. d10ListExp :: String -> Q Exp -- | Produces a pattern that can be used in a splice to match a particular -- D10 value. -- --
-- >>> :{
-- case (charD10Maybe '5') of
-- Just $(d10Pat 4) -> "A"
-- Just $(d10Pat 5) -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
-- You may wish to use the d10 quasi-quoter instead.
d10Pat :: Integer -> Q Pat
-- | Produces a pattern that can be used in a splice to match a particular
-- list of D10 values.
--
--
-- >>> :{
-- case (strD10ListMaybe "56") of
-- Just $(d10ListPat "42") -> "A"
-- Just $(d10ListPat "56") -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
-- You may wish to use the d10list quasi-quoter instead.
d10ListPat :: String -> Q Pat
-- | Convert a D10 to its underlying Char representation.
--
-- -- >>> d10Char [d10|7|] -- '7' --d10Char :: D10 -> Char -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or produce Nothing otherwise. -- --
-- isD10Char x = isJust (charD10Maybe x) ---- -- charD10Fail is a more general version of this function. -- --
-- >>> charD10Maybe '5' -- Just [d10|5|] ---- --
-- >>> charD10Maybe 'a' -- Nothing --charD10Maybe :: Char -> Maybe D10 -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or Left with an error message -- otherwise. -- --
-- >>> charD10Either '5' -- Right [d10|5|] ---- --
-- >>> charD10Either 'a' -- Left "d10 must be between 0 and 9" --charD10Either :: Char -> Either String D10 -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or fail with an error message -- otherwise. -- -- charD10Maybe is a specialized version of this function. -- --
-- >>> charD10Fail '5' :: IO D10 -- [d10|5|] ---- --
-- >>> charD10Fail 'a' :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --charD10Fail :: MonadFail m => Char -> m D10 -- | Convert a D10 to a String. -- --
-- d10Str x = [d10Char x] ---- --
-- >>> d10Str [d10|7|] -- "7" --d10Str :: D10 -> String -- | Convert a String to a D10 if it consists of exactly one -- character and that character is within the range '0' to -- '9', or produce Nothing otherwise. -- --
-- isD10Str x = isJust (strD10Maybe x) ---- -- strD10Fail is a more general version of this function. -- --
-- >>> strD10Maybe "5" -- Just [d10|5|] ---- --
-- >>> strD10Maybe "a" -- Nothing ---- --
-- >>> strD10Maybe "58" -- Nothing --strD10Maybe :: String -> Maybe D10 -- | Convert a String to a D10 if it consists of a single -- character and that character is within the range '0' to -- '9', or Left with an error message otherwise. -- --
-- >>> strD10Either "5" -- Right [d10|5|] ---- --
-- >>> strD10Either "a" -- Left "d10 must be between 0 and 9" ---- --
-- >>> strD10Either "58" -- Left "d10 must be a single character" --strD10Either :: String -> Either String D10 -- | Convert a String to a D10 if it consists of a single -- character and that character is within the range '0' to -- '9', or fail with an error message otherwise. -- -- strD10Maybe is a specialized version of this function. -- --
-- >>> strD10Fail "5" :: IO D10 -- [d10|5|] ---- --
-- >>> strD10Fail "a" :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> strD10Fail "58" :: IO D10 -- *** Exception: user error (d10 must be a single character) --strD10Fail :: MonadFail m => String -> m D10 -- | Convert a String to a list of D10 if all of the -- characters in the string are within the range '0' to -- '9', or produce Nothing otherwise. -- --
-- isD10ListStr x = isJust (strD10ListMaybe x) ---- -- strD10ListFail is a more general version of this function. -- --
-- >>> strD10ListMaybe "5" -- Just [d10list|5|] ---- --
-- >>> strD10ListMaybe "a" -- Nothing ---- --
-- >>> strD10ListMaybe "58" -- Just [d10list|58|] --strD10ListMaybe :: String -> Maybe [D10] -- | Convert a String to a D10 if all of the characters in -- the string fall within the range '0' to '9', or -- Left with an error message otherwise. -- --
-- >>> strD10ListEither "5" -- Right [d10list|5|] ---- --
-- >>> strD10ListEither "a" -- Left "d10 must be between 0 and 9" ---- --
-- >>> strD10ListEither "58" -- Right [d10list|58|] --strD10ListEither :: String -> Either String [D10] -- | Convert a String to a D10 if all of the characters in -- the string fall within the range '0' to '9', or -- fail with an error message otherwise. -- -- strD10ListMaybe is a specialized version of this function. -- --
-- >>> strD10ListFail "5" :: IO [D10] -- [d10list|5|] ---- --
-- >>> strD10ListFail "a" :: IO [D10] -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> strD10ListFail "58" :: IO [D10] -- [d10list|58|] --strD10ListFail :: MonadFail m => String -> m [D10] -- | Convert a D10 to a Natural. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Nat [d10|7|] -- 7 --d10Nat :: D10 -> Natural -- | Convert a Natural to a D10 if it is less than 10, or -- produce Nothing otherwise. -- --
-- isD10Nat x = isJust (natD10Maybe x) ---- -- integralD10Maybe, natD10Fail, and integralD10Fail -- are more general versions of this function. -- --
-- >>> natD10Maybe 5 -- Just [d10|5|] ---- --
-- >>> natD10Maybe 12 -- Nothing --natD10Maybe :: Natural -> Maybe D10 -- | Convert a Natural to a D10 if it is less than 10, or -- Left with an error message otherwise. -- --
-- >>> natD10Either 5 -- Right [d10|5|] ---- --
-- >>> natD10Either 12 -- Left "d10 must be less than 10" --natD10Either :: Natural -> Either String D10 -- | Convert a Natural to a D10 if it is less than 10, or -- fail with an error message otherwise. -- -- natD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> natD10Fail 5 :: IO D10 -- [d10|5|] ---- --
-- >>> natD10Fail 12 :: IO D10 -- *** Exception: user error (d10 must be less than 10) --natD10Fail :: MonadFail m => Natural -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- Natural. -- -- integralMod10 is a more general version of this function. -- --
-- >>> natMod10 56 -- [d10|6|] --natMod10 :: Natural -> D10 -- | Convert a D10 to an Integer. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Integer [d10|7|] -- 7 --d10Integer :: D10 -> Integer -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or produce Nothing otherwise. -- --
-- isD10Integer x = isJust (integerD10Maybe x) ---- -- integralD10Maybe, integerD10Fail, and -- integralD10Fail are more general versions of this function. -- --
-- >>> integerD10Maybe 5 -- Just [d10|5|] ---- --
-- >>> integerD10Maybe 12 -- Nothing ---- --
-- >>> integerD10Maybe (-5) -- Nothing --integerD10Maybe :: Integer -> Maybe D10 -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or Left with an error message otherwise. -- --
-- >>> integerD10Either 5 -- Right [d10|5|] ---- --
-- >>> integerD10Either 12 -- Left "d10 must be between 0 and 9" ---- --
-- >>> integerD10Either (-5) -- Left "d10 must be between 0 and 9" --integerD10Either :: Integer -> Either String D10 -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or fail with an error message otherwise. -- -- integerD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> integerD10Fail 5 :: IO D10 -- [d10|5|] ---- --
-- >>> integerD10Fail 12 :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> integerD10Fail (-5) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --integerD10Fail :: MonadFail m => Integer -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- Integer. -- -- integralMod10 is a more general version of this function. -- --
-- >>> integerMod10 56 -- [d10|6|] ---- --
-- >>> integerMod10 (-56) -- [d10|4|] --integerMod10 :: Integer -> D10 -- | Convert a D10 to an Int. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Int [d10|7|] -- 7 --d10Int :: D10 -> Int -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or produce Nothing otherwise. -- --
-- isD10Int x = isJust (intD10Maybe x) ---- -- integralD10Maybe, intD10Fail, and integralD10Fail -- are more general versions of this function. -- --
-- >>> intD10Maybe 5 -- Just [d10|5|] ---- --
-- >>> intD10Maybe 12 -- Nothing ---- --
-- >>> intD10Maybe (-5) -- Nothing --intD10Maybe :: Int -> Maybe D10 -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or Left with an error message otherwise. -- --
-- >>> intD10Either 5 -- Right [d10|5|] ---- --
-- >>> intD10Either 12 -- Left "d10 must be between 0 and 9" ---- --
-- >>> intD10Either (-5) -- Left "d10 must be between 0 and 9" --intD10Either :: Int -> Either String D10 -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or fail with an error message otherwise. -- -- intD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> intD10Fail 5 :: IO D10 -- [d10|5|] ---- --
-- >>> intD10Fail 12 :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> intD10Fail (-5) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --intD10Fail :: MonadFail m => Int -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- Int. -- -- integralMod10 is a more general version of this function. -- --
-- >>> intMod10 56 -- [d10|6|] ---- --
-- >>> intMod10 (-56) -- [d10|4|] --intMod10 :: Int -> D10 -- | Convert a D10 to any kind of number with a Num instance. -- -- Specialized versions of this function include d10Nat, -- d10Integer, and d10Int. -- --
-- >>> d10Num [d10|7|] :: Integer -- 7 --d10Num :: Num a => D10 -> a -- | Construct a D10 from any kind of number with an Integral -- instance, or produce Nothing if the number falls outside the -- range 0 to 9. -- --
-- isD10Integral x = isJust (integralD10Maybe x) ---- -- Specialized versions of this function include natD10Maybe, -- integerD10Maybe, and intD10Maybe. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> integralD10Maybe (5 :: Integer) -- Just [d10|5|] ---- --
-- >>> integralD10Maybe (12 :: Integer) -- Nothing ---- --
-- >>> integralD10Maybe ((-5) :: Integer) -- Nothing --integralD10Maybe :: Integral a => a -> Maybe D10 -- | Convert a number of a type that has an Integral instance to a -- D10 if it falls within the range 0 to 9, or Left with an -- error message otherwise. -- --
-- >>> integralD10Either (5 :: Integer) -- Right [d10|5|] ---- --
-- >>> integralD10Either (12 :: Integer) -- Left "d10 must be between 0 and 9" ---- --
-- >>> integralD10Either ((-5) :: Integer) -- Left "d10 must be between 0 and 9" --integralD10Either :: Integral a => a -> Either String D10 -- | Convert a number of a type that has an Integral instance to a -- D10 if it falls within the range 0 to 9, or fail with an -- error message otherwise. -- -- natD10Maybe, integerD10Maybe, intD10Maybe, -- integralD10Maybe, natD10Fail, integerD10Fail, and -- intD10Fail are all specialized versions of this function. -- --
-- >>> integralD10Fail (5 :: Integer) :: IO D10 -- [d10|5|] ---- --
-- >>> integralD10Fail (12 :: Integer) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> integralD10Fail ((-5) :: Integer) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --integralD10Fail :: (Integral a, MonadFail m) => a -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- number (whose type must have an instance of the Integral -- class). -- -- Specialized versions of this function include natMod10, -- integerMod10, and intMod10. -- --
-- >>> integralMod10 (56 :: Integer) -- [d10|6|] ---- --
-- >>> integralMod10 ((-56) :: Integer) -- [d10|4|] --integralMod10 :: Integral a => a -> D10 module D10.Char.Arithmetic -- | Addition modulo 10. -- --
-- >>> [d10|2|] + [d10|3|] -- [d10|5|] ---- --
-- >>> [d10|6|] + [d10|7|] -- [d10|3|] --(+) :: D10 -> D10 -> D10 -- | Subtraction modulo 10. -- --
-- >>> [d10|7|] - [d10|5|] -- [d10|2|] ---- --
-- >>> [d10|3|] - [d10|7|] -- [d10|6|] --(-) :: D10 -> D10 -> D10 -- | Multiplication modulo 10. -- --
-- >>> [d10|2|] * [d10|4|] -- [d10|8|] ---- --
-- >>> [d10|7|] * [d10|8|] -- [d10|6|] --(*) :: D10 -> D10 -> D10 module D10.Safe.Type -- | A whole number between 0 and 9 data D10 -- | Zero D0 :: D10 -- | One D1 :: D10 -- | Two D2 :: D10 -- | Three D3 :: D10 -- | Four D4 :: D10 -- | Five D5 :: D10 -- | Six D6 :: D10 -- | Seven D7 :: D10 -- | Eight D8 :: D10 -- | Nine D9 :: D10 instance GHC.Generics.Generic D10.Safe.Type.D10 instance Data.Data.Data D10.Safe.Type.D10 instance GHC.Show.Show D10.Safe.Type.D10 instance GHC.Classes.Ord D10.Safe.Type.D10 instance GHC.Classes.Eq D10.Safe.Type.D10 instance GHC.Enum.Enum D10.Safe.Type.D10 instance GHC.Enum.Bounded D10.Safe.Type.D10 module D10.Safe.Conversions -- | Convert a D10 to its underlying Char representation. -- --
-- >>> d10Char D7 -- '7' --d10Char :: D10 -> Char -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or produce Nothing otherwise. -- --
-- isD10Char x = isJust (charD10Maybe x) ---- -- charD10Fail is a more general version of this function. -- --
-- >>> charD10Maybe '5' -- Just D5 ---- --
-- >>> charD10Maybe 'a' -- Nothing --charD10Maybe :: Char -> Maybe D10 -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or Left with an error message -- otherwise. -- --
-- >>> charD10Either '5' -- Right D5 ---- --
-- >>> charD10Either 'a' -- Left "d10 must be between 0 and 9" --charD10Either :: Char -> Either String D10 -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or fail with an error message -- otherwise. -- -- charD10Maybe is a specialized version of this function. -- --
-- >>> charD10Fail '5' :: IO D10 -- D5 ---- --
-- >>> charD10Fail 'a' :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --charD10Fail :: MonadFail m => Char -> m D10 -- | Convert a D10 to a String. -- --
-- d10Str x = [d10Char x] ---- --
-- >>> d10Str D7 -- "7" --d10Str :: D10 -> String -- | Convert a String to a D10 if it consists of exactly one -- character and that character is within the range '0' to -- '9', or produce Nothing otherwise. -- --
-- isD10Str x = isJust (strD10Maybe x) ---- -- strD10Fail is a more general version of this function. -- --
-- >>> strD10Maybe "5" -- Just D5 ---- --
-- >>> strD10Maybe "a" -- Nothing ---- --
-- >>> strD10Maybe "58" -- Nothing --strD10Maybe :: String -> Maybe D10 -- | Convert a String to a D10 if it consists of a single -- character and that character is within the range '0' to -- '9', or Left with an error message otherwise. -- --
-- >>> strD10Either "5" -- Right D5 ---- --
-- >>> strD10Either "a" -- Left "d10 must be between 0 and 9" ---- --
-- >>> strD10Either "58" -- Left "d10 must be a single character" --strD10Either :: String -> Either String D10 -- | Convert a String to a D10 if it consists of a single -- character and that character is within the range '0' to -- '9', or fail with an error message otherwise. -- -- strD10Maybe is a specialized version of this function. -- --
-- >>> strD10Fail "5" :: IO D10 -- D5 ---- --
-- >>> strD10Fail "a" :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> strD10Fail "58" :: IO D10 -- *** Exception: user error (d10 must be a single character) --strD10Fail :: MonadFail m => String -> m D10 -- | Convert a String to a list of D10 if all of the -- characters in the string are within the range '0' to -- '9', or produce Nothing otherwise. -- --
-- isD10ListStr x = isJust (strD10ListMaybe x) ---- -- strD10ListFail is a more general version of this function. -- --
-- >>> strD10ListMaybe "5" -- Just [D5] ---- --
-- >>> strD10ListMaybe "a" -- Nothing ---- --
-- >>> strD10ListMaybe "58" -- Just [D5,D8] --strD10ListMaybe :: String -> Maybe [D10] -- | Convert a String to a D10 if all of the characters in -- the string fall within the range '0' to '9', or -- Left with an error message otherwise. -- --
-- >>> strD10ListEither "5" -- Right [D5] ---- --
-- >>> strD10ListEither "a" -- Left "d10 must be between 0 and 9" ---- --
-- >>> strD10ListEither "58" -- Right [D5,D8] --strD10ListEither :: String -> Either String [D10] -- | Convert a String to a D10 if all of the characters in -- the string fall within the range '0' to '9', or -- fail with an error message otherwise. -- -- strD10ListMaybe is a specialized version of this function. -- --
-- >>> strD10ListFail "5" :: IO [D10] -- [D5] ---- --
-- >>> strD10ListFail "a" :: IO [D10] -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> strD10ListFail "58" :: IO [D10] -- [D5,D8] --strD10ListFail :: MonadFail m => String -> m [D10] -- | Convert a D10 to a Natural. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Nat D7 -- 7 --d10Nat :: D10 -> Natural -- | Convert a Natural to a D10 if it is less than 10, or -- produce Nothing otherwise. -- --
-- isD10Nat x = isJust (natD10Maybe x) ---- -- integralD10Maybe, natD10Fail, and integralD10Fail -- are more general versions of this function. -- --
-- >>> natD10Maybe 5 -- Just D5 ---- --
-- >>> natD10Maybe 12 -- Nothing --natD10Maybe :: Natural -> Maybe D10 -- | Convert a Natural to a D10 if it is less than 10, or -- Left with an error message otherwise. -- --
-- >>> natD10Either 5 -- Right D5 ---- --
-- >>> natD10Either 12 -- Left "d10 must be less than 10" --natD10Either :: Natural -> Either String D10 -- | Convert a Natural to a D10 if it is less than 10, or -- fail with an error message otherwise. -- -- natD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> natD10Fail 5 :: IO D10 -- D5 ---- --
-- >>> natD10Fail 12 :: IO D10 -- *** Exception: user error (d10 must be less than 10) --natD10Fail :: MonadFail m => Natural -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- Natural. -- -- integralMod10 is a more general version of this function. -- --
-- >>> natMod10 56 -- D6 --natMod10 :: Natural -> D10 -- | Convert a D10 to an Integer. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Integer D7 -- 7 --d10Integer :: D10 -> Integer -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or produce Nothing otherwise. -- --
-- isD10Integer x = isJust (integerD10Maybe x) ---- -- integralD10Maybe, integerD10Fail, and -- integralD10Fail are more general versions of this function. -- --
-- >>> integerD10Maybe 5 -- Just D5 ---- --
-- >>> integerD10Maybe 12 -- Nothing ---- --
-- >>> integerD10Maybe (-5) -- Nothing --integerD10Maybe :: Integer -> Maybe D10 -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or Left with an error message otherwise. -- --
-- >>> integerD10Either 5 -- Right D5 ---- --
-- >>> integerD10Either 12 -- Left "d10 must be between 0 and 9" ---- --
-- >>> integerD10Either (-5) -- Left "d10 must be between 0 and 9" --integerD10Either :: Integer -> Either String D10 -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or fail with an error message otherwise. -- -- integerD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> integerD10Fail 5 :: IO D10 -- D5 ---- --
-- >>> integerD10Fail 12 :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> integerD10Fail (-5) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --integerD10Fail :: MonadFail m => Integer -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- Integer. -- -- integralMod10 is a more general version of this function. -- --
-- >>> integerMod10 56 -- D6 ---- --
-- >>> integerMod10 (-56) -- D4 --integerMod10 :: Integer -> D10 -- | Convert a D10 to an Int. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Int D7 -- 7 --d10Int :: D10 -> Int -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or produce Nothing otherwise. -- --
-- isD10Int x = isJust (intD10Maybe x) ---- -- integralD10Maybe, intD10Fail, and integralD10Fail -- are more general versions of this function. -- --
-- >>> intD10Maybe 5 -- Just D5 ---- --
-- >>> intD10Maybe 12 -- Nothing ---- --
-- >>> intD10Maybe (-5) -- Nothing --intD10Maybe :: Int -> Maybe D10 -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or Left with an error message otherwise. -- --
-- >>> intD10Either 5 -- Right D5 ---- --
-- >>> intD10Either 12 -- Left "d10 must be between 0 and 9" ---- --
-- >>> intD10Either (-5) -- Left "d10 must be between 0 and 9" --intD10Either :: Int -> Either String D10 -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or fail with an error message otherwise. -- -- intD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> intD10Fail 5 :: IO D10 -- D5 ---- --
-- >>> intD10Fail 12 :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> intD10Fail (-5) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --intD10Fail :: MonadFail m => Int -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- Int. -- -- integralMod10 is a more general version of this function. -- --
-- >>> intMod10 56 -- D6 ---- --
-- >>> intMod10 (-56) -- D4 --intMod10 :: Int -> D10 -- | Convert a D10 to any kind of number with a Num instance. -- -- Specialized versions of this function include d10Nat, -- d10Integer, and d10Int. -- --
-- >>> d10Num D7 :: Integer -- 7 --d10Num :: Num a => D10 -> a -- | Construct a D10 from any kind of number with an Integral -- instance, or produce Nothing if the number falls outside the -- range 0 to 9. -- --
-- isD10Integral x = isJust (integralD10Maybe x) ---- -- Specialized versions of this function include natD10Maybe, -- integerD10Maybe, and intD10Maybe. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> integralD10Maybe (5 :: Integer) -- Just D5 ---- --
-- >>> integralD10Maybe (12 :: Integer) -- Nothing ---- --
-- >>> integralD10Maybe ((-5) :: Integer) -- Nothing --integralD10Maybe :: Integral a => a -> Maybe D10 -- | Convert a number of a type that has an Integral instance to a -- D10 if it falls within the range 0 to 9, or Left with an -- error message otherwise. -- --
-- >>> integralD10Either (5 :: Integer) -- Right D5 ---- --
-- >>> integralD10Either (12 :: Integer) -- Left "d10 must be between 0 and 9" ---- --
-- >>> integralD10Either ((-5) :: Integer) -- Left "d10 must be between 0 and 9" --integralD10Either :: Integral a => a -> Either String D10 -- | Convert a number of a type that has an Integral instance to a -- D10 if it falls within the range 0 to 9, or fail with an -- error message otherwise. -- -- natD10Maybe, integerD10Maybe, intD10Maybe, -- integralD10Maybe, natD10Fail, integerD10Fail, and -- intD10Fail are all specialized versions of this function. -- --
-- >>> integralD10Fail (5 :: Integer) :: IO D10 -- D5 ---- --
-- >>> integralD10Fail (12 :: Integer) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> integralD10Fail ((-5) :: Integer) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --integralD10Fail :: (Integral a, MonadFail m) => a -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- number (whose type must have an instance of the Integral -- class). -- -- Specialized versions of this function include natMod10, -- integerMod10, and intMod10. -- --
-- >>> integralMod10 (56 :: Integer) -- D6 ---- --
-- >>> integralMod10 ((-56) :: Integer) -- D4 --integralMod10 :: Integral a => a -> D10 module D10.Safe.Splices -- | Produces an expression of type [D10] that can be -- used in a Template Haskell splice. -- --
-- >>> $(d10ListExp "") -- [] ---- --
-- >>> $(d10ListExp "5") -- [D5] ---- --
-- >>> $(d10ListExp "58") -- [D5,D8] ---- --
-- >>> $(d10ListExp "a") -- ... -- ... d10 must be between 0 and 9 -- ... ---- -- You may also be interested in d10list, a quasi-quoter which -- does something similar. d10ListExp :: String -> Q Exp -- | Produces a pattern that can be used in a splice to match a particular -- list of D10 values. -- --
-- >>> :{
-- case [D5, D6] of
-- $(d10ListPat "42") -> "A"
-- $(d10ListPat "56") -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
-- You may also be interested in d10list, a quasi-quoter which
-- does something similar.
d10ListPat :: String -> Q Pat
module D10.Safe.Quotes
-- | A list of base-10 digits.
--
-- This quasi-quoter, when used as an expression, produces a value of
-- type [D10].
--
-- -- >>> [d10list||] -- [] ---- --
-- >>> [d10list|5|] -- [D5] ---- --
-- >>> [d10list|58|] -- [D5,D8] ---- --
-- >>> [d10list|a|] -- ... -- ... d10 must be between 0 and 9 -- ... ---- -- This quasi-quoter can also be used as a pattern. -- --
-- >>> :{
-- case [D5, D6] of
-- [d10list|41|] -> "A"
-- [d10list|56|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
--
-- >>> :{
-- case [D5, D6] of
-- [d10list|4x|] -> "A"
-- [d10list|56|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- ...
-- ... d10 must be between 0 and 9
-- ...
--
d10list :: QuasiQuoter
-- | Defines a D10 type as D0 | D1 | D2 |
-- D3 | D4 | D5 | D6 | D7 | D8
-- | D9.
module D10.Safe
-- | A whole number between 0 and 9
data D10
-- | Zero
D0 :: D10
-- | One
D1 :: D10
-- | Two
D2 :: D10
-- | Three
D3 :: D10
-- | Four
D4 :: D10
-- | Five
D5 :: D10
-- | Six
D6 :: D10
-- | Seven
D7 :: D10
-- | Eight
D8 :: D10
-- | Nine
D9 :: D10
-- | A list of base-10 digits.
--
-- This quasi-quoter, when used as an expression, produces a value of
-- type [D10].
--
-- -- >>> [d10list||] -- [] ---- --
-- >>> [d10list|5|] -- [D5] ---- --
-- >>> [d10list|58|] -- [D5,D8] ---- --
-- >>> [d10list|a|] -- ... -- ... d10 must be between 0 and 9 -- ... ---- -- This quasi-quoter can also be used as a pattern. -- --
-- >>> :{
-- case [D5, D6] of
-- [d10list|41|] -> "A"
-- [d10list|56|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
--
-- >>> :{
-- case [D5, D6] of
-- [d10list|4x|] -> "A"
-- [d10list|56|] -> "B"
-- _ -> "C"
--
-- >>> :}
-- ...
-- ... d10 must be between 0 and 9
-- ...
--
d10list :: QuasiQuoter
-- | Produces an expression of type [D10] that can be
-- used in a Template Haskell splice.
--
-- -- >>> $(d10ListExp "") -- [] ---- --
-- >>> $(d10ListExp "5") -- [D5] ---- --
-- >>> $(d10ListExp "58") -- [D5,D8] ---- --
-- >>> $(d10ListExp "a") -- ... -- ... d10 must be between 0 and 9 -- ... ---- -- You may also be interested in d10list, a quasi-quoter which -- does something similar. d10ListExp :: String -> Q Exp -- | Produces a pattern that can be used in a splice to match a particular -- list of D10 values. -- --
-- >>> :{
-- case [D5, D6] of
-- $(d10ListPat "42") -> "A"
-- $(d10ListPat "56") -> "B"
-- _ -> "C"
--
-- >>> :}
-- "B"
--
--
-- You may also be interested in d10list, a quasi-quoter which
-- does something similar.
d10ListPat :: String -> Q Pat
-- | Convert a D10 to its underlying Char representation.
--
-- -- >>> d10Char D7 -- '7' --d10Char :: D10 -> Char -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or produce Nothing otherwise. -- --
-- isD10Char x = isJust (charD10Maybe x) ---- -- charD10Fail is a more general version of this function. -- --
-- >>> charD10Maybe '5' -- Just D5 ---- --
-- >>> charD10Maybe 'a' -- Nothing --charD10Maybe :: Char -> Maybe D10 -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or Left with an error message -- otherwise. -- --
-- >>> charD10Either '5' -- Right D5 ---- --
-- >>> charD10Either 'a' -- Left "d10 must be between 0 and 9" --charD10Either :: Char -> Either String D10 -- | Convert a Char to a D10 if it is within the range -- '0' to '9', or fail with an error message -- otherwise. -- -- charD10Maybe is a specialized version of this function. -- --
-- >>> charD10Fail '5' :: IO D10 -- D5 ---- --
-- >>> charD10Fail 'a' :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --charD10Fail :: MonadFail m => Char -> m D10 -- | Convert a D10 to a String. -- --
-- d10Str x = [d10Char x] ---- --
-- >>> d10Str D7 -- "7" --d10Str :: D10 -> String -- | Convert a String to a D10 if it consists of exactly one -- character and that character is within the range '0' to -- '9', or produce Nothing otherwise. -- --
-- isD10Str x = isJust (strD10Maybe x) ---- -- strD10Fail is a more general version of this function. -- --
-- >>> strD10Maybe "5" -- Just D5 ---- --
-- >>> strD10Maybe "a" -- Nothing ---- --
-- >>> strD10Maybe "58" -- Nothing --strD10Maybe :: String -> Maybe D10 -- | Convert a String to a D10 if it consists of a single -- character and that character is within the range '0' to -- '9', or Left with an error message otherwise. -- --
-- >>> strD10Either "5" -- Right D5 ---- --
-- >>> strD10Either "a" -- Left "d10 must be between 0 and 9" ---- --
-- >>> strD10Either "58" -- Left "d10 must be a single character" --strD10Either :: String -> Either String D10 -- | Convert a String to a D10 if it consists of a single -- character and that character is within the range '0' to -- '9', or fail with an error message otherwise. -- -- strD10Maybe is a specialized version of this function. -- --
-- >>> strD10Fail "5" :: IO D10 -- D5 ---- --
-- >>> strD10Fail "a" :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> strD10Fail "58" :: IO D10 -- *** Exception: user error (d10 must be a single character) --strD10Fail :: MonadFail m => String -> m D10 -- | Convert a String to a list of D10 if all of the -- characters in the string are within the range '0' to -- '9', or produce Nothing otherwise. -- --
-- isD10ListStr x = isJust (strD10ListMaybe x) ---- -- strD10ListFail is a more general version of this function. -- --
-- >>> strD10ListMaybe "5" -- Just [D5] ---- --
-- >>> strD10ListMaybe "a" -- Nothing ---- --
-- >>> strD10ListMaybe "58" -- Just [D5,D8] --strD10ListMaybe :: String -> Maybe [D10] -- | Convert a String to a D10 if all of the characters in -- the string fall within the range '0' to '9', or -- Left with an error message otherwise. -- --
-- >>> strD10ListEither "5" -- Right [D5] ---- --
-- >>> strD10ListEither "a" -- Left "d10 must be between 0 and 9" ---- --
-- >>> strD10ListEither "58" -- Right [D5,D8] --strD10ListEither :: String -> Either String [D10] -- | Convert a String to a D10 if all of the characters in -- the string fall within the range '0' to '9', or -- fail with an error message otherwise. -- -- strD10ListMaybe is a specialized version of this function. -- --
-- >>> strD10ListFail "5" :: IO [D10] -- [D5] ---- --
-- >>> strD10ListFail "a" :: IO [D10] -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> strD10ListFail "58" :: IO [D10] -- [D5,D8] --strD10ListFail :: MonadFail m => String -> m [D10] -- | Convert a D10 to a Natural. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Nat D7 -- 7 --d10Nat :: D10 -> Natural -- | Convert a Natural to a D10 if it is less than 10, or -- produce Nothing otherwise. -- --
-- isD10Nat x = isJust (natD10Maybe x) ---- -- integralD10Maybe, natD10Fail, and integralD10Fail -- are more general versions of this function. -- --
-- >>> natD10Maybe 5 -- Just D5 ---- --
-- >>> natD10Maybe 12 -- Nothing --natD10Maybe :: Natural -> Maybe D10 -- | Convert a Natural to a D10 if it is less than 10, or -- Left with an error message otherwise. -- --
-- >>> natD10Either 5 -- Right D5 ---- --
-- >>> natD10Either 12 -- Left "d10 must be less than 10" --natD10Either :: Natural -> Either String D10 -- | Convert a Natural to a D10 if it is less than 10, or -- fail with an error message otherwise. -- -- natD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> natD10Fail 5 :: IO D10 -- D5 ---- --
-- >>> natD10Fail 12 :: IO D10 -- *** Exception: user error (d10 must be less than 10) --natD10Fail :: MonadFail m => Natural -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- Natural. -- -- integralMod10 is a more general version of this function. -- --
-- >>> natMod10 56 -- D6 --natMod10 :: Natural -> D10 -- | Convert a D10 to an Integer. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Integer D7 -- 7 --d10Integer :: D10 -> Integer -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or produce Nothing otherwise. -- --
-- isD10Integer x = isJust (integerD10Maybe x) ---- -- integralD10Maybe, integerD10Fail, and -- integralD10Fail are more general versions of this function. -- --
-- >>> integerD10Maybe 5 -- Just D5 ---- --
-- >>> integerD10Maybe 12 -- Nothing ---- --
-- >>> integerD10Maybe (-5) -- Nothing --integerD10Maybe :: Integer -> Maybe D10 -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or Left with an error message otherwise. -- --
-- >>> integerD10Either 5 -- Right D5 ---- --
-- >>> integerD10Either 12 -- Left "d10 must be between 0 and 9" ---- --
-- >>> integerD10Either (-5) -- Left "d10 must be between 0 and 9" --integerD10Either :: Integer -> Either String D10 -- | Convert an Integer to a D10 if it is within the range 0 -- to 9, or fail with an error message otherwise. -- -- integerD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> integerD10Fail 5 :: IO D10 -- D5 ---- --
-- >>> integerD10Fail 12 :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> integerD10Fail (-5) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --integerD10Fail :: MonadFail m => Integer -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- Integer. -- -- integralMod10 is a more general version of this function. -- --
-- >>> integerMod10 56 -- D6 ---- --
-- >>> integerMod10 (-56) -- D4 --integerMod10 :: Integer -> D10 -- | Convert a D10 to an Int. -- -- d10Num is a more general version of this function. -- --
-- >>> d10Int D7 -- 7 --d10Int :: D10 -> Int -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or produce Nothing otherwise. -- --
-- isD10Int x = isJust (intD10Maybe x) ---- -- integralD10Maybe, intD10Fail, and integralD10Fail -- are more general versions of this function. -- --
-- >>> intD10Maybe 5 -- Just D5 ---- --
-- >>> intD10Maybe 12 -- Nothing ---- --
-- >>> intD10Maybe (-5) -- Nothing --intD10Maybe :: Int -> Maybe D10 -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or Left with an error message otherwise. -- --
-- >>> intD10Either 5 -- Right D5 ---- --
-- >>> intD10Either 12 -- Left "d10 must be between 0 and 9" ---- --
-- >>> intD10Either (-5) -- Left "d10 must be between 0 and 9" --intD10Either :: Int -> Either String D10 -- | Convert an Int to a D10 if it is within the range 0 to -- 9, or fail with an error message otherwise. -- -- intD10Maybe is a specialized version of this function. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> intD10Fail 5 :: IO D10 -- D5 ---- --
-- >>> intD10Fail 12 :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> intD10Fail (-5) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --intD10Fail :: MonadFail m => Int -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- Int. -- -- integralMod10 is a more general version of this function. -- --
-- >>> intMod10 56 -- D6 ---- --
-- >>> intMod10 (-56) -- D4 --intMod10 :: Int -> D10 -- | Convert a D10 to any kind of number with a Num instance. -- -- Specialized versions of this function include d10Nat, -- d10Integer, and d10Int. -- --
-- >>> d10Num D7 :: Integer -- 7 --d10Num :: Num a => D10 -> a -- | Construct a D10 from any kind of number with an Integral -- instance, or produce Nothing if the number falls outside the -- range 0 to 9. -- --
-- isD10Integral x = isJust (integralD10Maybe x) ---- -- Specialized versions of this function include natD10Maybe, -- integerD10Maybe, and intD10Maybe. -- -- integralD10Fail is a more general version of this function. -- --
-- >>> integralD10Maybe (5 :: Integer) -- Just D5 ---- --
-- >>> integralD10Maybe (12 :: Integer) -- Nothing ---- --
-- >>> integralD10Maybe ((-5) :: Integer) -- Nothing --integralD10Maybe :: Integral a => a -> Maybe D10 -- | Convert a number of a type that has an Integral instance to a -- D10 if it falls within the range 0 to 9, or Left with an -- error message otherwise. -- --
-- >>> integralD10Either (5 :: Integer) -- Right D5 ---- --
-- >>> integralD10Either (12 :: Integer) -- Left "d10 must be between 0 and 9" ---- --
-- >>> integralD10Either ((-5) :: Integer) -- Left "d10 must be between 0 and 9" --integralD10Either :: Integral a => a -> Either String D10 -- | Convert a number of a type that has an Integral instance to a -- D10 if it falls within the range 0 to 9, or fail with an -- error message otherwise. -- -- natD10Maybe, integerD10Maybe, intD10Maybe, -- integralD10Maybe, natD10Fail, integerD10Fail, and -- intD10Fail are all specialized versions of this function. -- --
-- >>> integralD10Fail (5 :: Integer) :: IO D10 -- D5 ---- --
-- >>> integralD10Fail (12 :: Integer) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) ---- --
-- >>> integralD10Fail ((-5) :: Integer) :: IO D10 -- *** Exception: user error (d10 must be between 0 and 9) --integralD10Fail :: (Integral a, MonadFail m) => a -> m D10 -- | The D10 which is uniquely congruent modulo 10 to the given -- number (whose type must have an instance of the Integral -- class). -- -- Specialized versions of this function include natMod10, -- integerMod10, and intMod10. -- --
-- >>> integralMod10 (56 :: Integer) -- D6 ---- --
-- >>> integralMod10 ((-56) :: Integer) -- D4 --integralMod10 :: Integral a => a -> D10 module D10.Safe.Arithmetic -- | Addition modulo 10. -- --
-- >>> D2 + D3 -- D5 ---- --
-- >>> D6 + D7 -- D3 --(+) :: D10 -> D10 -> D10 -- | Subtraction modulo 10. -- --
-- >>> D7 - D5 -- D2 ---- --
-- >>> D3 - D7 -- D6 --(-) :: D10 -> D10 -> D10 -- | Multiplication modulo 10. -- --
-- >>> D2 * D4 -- D8 -- -- >>> D7 * D8 -- D6 --(*) :: D10 -> D10 -> D10