modular-arithmetic 1.0.1.0 → 1.0.1.1
raw patch · 2 files changed
+18/−20 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- modular-arithmetic.cabal +5/−1
- src/Data/Modular.hs +13/−19
modular-arithmetic.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/ name: modular-arithmetic-version: 1.0.1.0+version: 1.0.1.1 synopsis: A type for integers modulo some constant. description: This module provides a convenient type for working with@@ -20,6 +20,10 @@ category: Math build-type: Simple cabal-version: >=1.8++source-repository head+ type: git+ location: git://github.com/TikhonJelvis/modular-arithmetic.git library hs-source-dirs: src
src/Data/Modular.hs view
@@ -8,22 +8,20 @@ -- 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.+-- 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--- @+-- > 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}.)+-- 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@@ -31,17 +29,13 @@ -- -- Here is a quick example: -- --- @--- *Data.Modular> (10 :: ℤ/7) * (11 :: ℤ/7)--- 5--- @+-- > *Data.Modular> (10 :: ℤ/7) * (11 :: ℤ/7)+-- > 5 -- -- It also works correctly with negative numeric literals: -- --- @--- *Data.Modular> (-10 :: ℤ/7) * (11 :: ℤ/7)--- 2--- @+-- > *Data.Modular> (-10 :: ℤ/7) * (11 :: ℤ/7)+-- > 2 module Data.Modular (unMod, toMod, toMod', Mod, (/)(), ℤ) where @@ -79,7 +73,7 @@ -- | Wraps an integral number to a mod, converting between integral -- types. toMod' :: forall n i j. (Integral i, Integral j, SingI n) => i -> j `Mod` n-toMod' = toMod . fromIntegral+toMod' i = toMod . fromIntegral $ i `mod` (fromInteger $ fromSing (sing :: Sing n)) instance Show i => Show (i `Mod` n) where show (Mod i) = show i instance (Read i, Integral i, SingI n) => Read (i `Mod` n)