-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A type for integers modulo some constant. -- -- 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. Integer Mod 7 -- is the type of integers (mod 7) backed by Integer. We also -- have some cute syntax for these types like ℤ/7 for integers -- modulo 7. @package modular-arithmetic @version 1.2.1.2 -- | Types for working with integers modulo some constant. module Data.Modular -- | Wraps an underlying Integeral type i in a newtype -- annotated with the bound n. data Mod i (n :: Nat) -- | Extract the underlying integral value from a modular type. unMod :: i `Mod` n -> i -- | Injects a value of the underlying type into the modulus type, wrapping -- as appropriate. toMod :: forall n i. (Integral i, KnownNat n) => i -> i `Mod` n -- | Wraps an integral number, converting between integral types. toMod' :: forall n i j. (Integral i, Integral j, KnownNat n) => i -> j `Mod` n -- | The modular inverse. -- --
--   >>> inv 3 :: ℤ/7
--   5
--   
--   >>> 3 * 5 :: ℤ/7
--   1
--   
-- -- Note that only numbers coprime to n have an inverse modulo -- n: -- --
--   inv 6 :: ℤ/15
--   
-- -- inv :: forall n i. (KnownNat n, Integral i) => Mod i n -> Mod i n -- | 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 -- | Convert an integral number i into a Mod value -- given modular bound n at type level. modVal :: forall i proxy n. (Integral i, KnownNat n) => i -> proxy n -> Mod i n -- | A modular number with an unknown bound. data SomeMod i -- | Convert an integral number i into a Mod value -- with an unknown modulus. someModVal :: Integral i => i -> Integer -> Maybe (SomeMod i) instance GHC.Classes.Ord i => GHC.Classes.Ord (Data.Modular.Mod i n) instance GHC.Classes.Eq i => GHC.Classes.Eq (Data.Modular.Mod i n) instance GHC.Show.Show i => GHC.Show.Show (Data.Modular.Mod i n) instance (GHC.Read.Read i, GHC.Real.Integral i, GHC.TypeLits.KnownNat n) => GHC.Read.Read (Data.Modular.Mod i n) instance (GHC.Real.Integral i, GHC.TypeLits.KnownNat n) => GHC.Num.Num (Data.Modular.Mod i n) instance (GHC.Real.Integral i, GHC.TypeLits.KnownNat n) => GHC.Enum.Enum (Data.Modular.Mod i n) instance (GHC.Real.Integral i, GHC.TypeLits.KnownNat n) => GHC.Enum.Bounded (Data.Modular.Mod i n) instance (GHC.Real.Integral i, GHC.TypeLits.KnownNat n) => GHC.Real.Real (Data.Modular.Mod i n) instance (GHC.Real.Integral i, GHC.TypeLits.KnownNat n) => GHC.Real.Integral (Data.Modular.Mod i n) instance GHC.Show.Show i => GHC.Show.Show (Data.Modular.SomeMod i)