-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A type for integers modulo some constant.
--
-- This module provides a convenient type for working with integers
-- modulo some constant. It saves you from manually wrapping numeric
-- operations all over the place and prevents a range of simple mistakes.
-- It also provides some really cute syntax for these types like
-- ℤ/7 for integers modulo 7.
@package modular-arithmetic
@version 1.0.0.0
-- | This module provides types for working with integers modulo some
-- constant.
--
-- This module uses some new Haskell features introduced in 7.6. In
-- particular, it needs DataKinds and type literals (GHC.TypeLits). The
-- TypeOperators extension is needed for the nice infix syntax.
--
-- These types are created with the type constructor Mod (or its
-- synonym /). To work with integers mod 7, you could write:
-- Int Mod 7 Integer Mod 7 Integer/7 ℤ/7
--
-- (The last is a synonym for Integer provided by this library.
-- In Emacs, you can use the Tex input mode to type it with Bbb{Z}.)
--
-- All the usual typeclasses are defined for these types. You can also
-- get the constant using bound or extract the underlying value
-- using unMod.
--
-- Here is a quick example: *Data.Modular> (10 :: ℤ7) * (11 ::
-- ℤ7) 5
--
-- It also works correctly with negative numeric literals:
-- *Data.Modular> (-10 :: ℤ7) * (11 :: ℤ7) 2
module Data.Modular
-- | Extract the underlying integral value from a modular type.
unMod :: i Mod n -> i
-- | Wraps the underlying type into the modular type, wrapping as
-- appropriate.
toMod :: (Integral i, SingI n) => i -> i Mod n
-- | The actual type, wrapping an underlying Integeral type
-- i in a newtype annotated with the bound.
data Mod i (n :: Nat)
-- | A synonym for Mod, inspired by the ℤ/n syntax from
-- mathematics.
type (/) = Mod
-- | A synonym for Integer, also inspired by the ℤ/n syntax.
type ℤ = Integer
instance Eq i => Eq (Mod i n)
instance Ord i => Ord (Mod i n)
instance (Integral i, SingI Nat n) => Integral (Mod i n)
instance (Integral i, SingI Nat n) => Real (Mod i n)
instance (Integral i, SingI Nat n) => Bounded (Mod i n)
instance (Integral i, SingI Nat n) => Enum (Mod i n)
instance (Integral i, SingI Nat n) => Num (Mod i n)
instance (Read i, Integral i, SingI Nat n) => Read (Mod i n)
instance Show i => Show (Mod i n)