modular 0.1.0.5 → 0.1.0.6
raw patch · 2 files changed
+13/−17 lines, 2 filesdep ~base
Dependency ranges changed: base
Files
- modular.cabal +4/−5
- src/Numeric/Modular.hs +9/−12
modular.cabal view
@@ -4,12 +4,12 @@ -- -- see: https://github.com/sol/hpack ----- hash: d5b462428189af88ae02486a529c92196e39e6c03058f59489d452e1fd9ee083+-- hash: 8b8be5a6a4111f28f05f23a955f6eb1b223646287747327c9a378a686e96670e name: modular-version: 0.1.0.5+version: 0.1.0.6 synopsis: Type-safe modular arithmetic-description: Please the documentation on GitHub at <https://github.com/pgujjula/modular>+description: Please the module documentation for Numeric.Modular. category: Math homepage: https://github.com/pgujjula/modular#readme bug-reports: https://github.com/pgujjula/modular/issues@@ -34,9 +34,8 @@ Paths_modular hs-source-dirs: src- default-extensions: ExplicitNamespaces ghc-options: -Wall build-depends:- base >=4.7 && <4.12+ base >=4.7 && <5 , ghc-typelits-knownnat >=0.5 && <1 default-language: Haskell2010
src/Numeric/Modular.hs view
@@ -41,7 +41,12 @@ 33479467020524411041 -} -{-# LANGUAGE DataKinds, ExplicitNamespaces, TypeFamilies, TypeOperators, GADTs, Rank2Types, ScopedTypeVariables #-}+{-# LANGUAGE DataKinds, TypeFamilies, TypeOperators, GADTs, Rank2Types, ScopedTypeVariables, CPP #-}+#ifdef MIN_VERSION_GLASGOW_HASKELL+#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)+{-# LANGUAGE NoStarIsType #-}+#endif+#endif {-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-} module Numeric.Modular@@ -51,15 +56,7 @@ ) where import Data.Proxy (Proxy(..))-import GHC.TypeLits- ( Nat- , KnownNat- , type (+)- , natVal- )---- GHC weirdness won't let us import 'type (*)'-import qualified GHC.TypeLits as L+import GHC.TypeLits (Nat, KnownNat, type (*), type (+), natVal) {-| Data type to represent an integer modulo `n`.@@ -74,7 +71,7 @@ In @withMod m a@ * @m@ is the modulus.- * @a@ is a polymorphic value that can take on the type @'Mod' m@ for any @a@.+ * @a@ is a value that can take on the type @'Mod' m@ for any @a@. * @withMod m a@ equals @a@ interpreted modulo @m@. > x = mkMod 17@@ -103,7 +100,7 @@ reifyInteger :: Integer -> (forall n. (KnownNat n) => Proxy n -> w) -> w reifyInteger 0 f = f (Proxy :: Proxy 0) reifyInteger n f- | even n = reifyInteger (n `div` 2) (\(Proxy :: Proxy n) -> f (Proxy :: Proxy (n L.* 2)))+ | even n = reifyInteger (n `div` 2) (\(Proxy :: Proxy n) -> f (Proxy :: Proxy (n * 2))) | otherwise = reifyInteger (n - 1) (\(Proxy :: Proxy n) -> f (Proxy :: Proxy (n + 1))) instance Eq (Mod m) where