summaryrefslogtreecommitdiff
path: root/packages/base/src/Internal/Modular.hs
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src/Internal/Modular.hs')
-rw-r--r--packages/base/src/Internal/Modular.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/packages/base/src/Internal/Modular.hs b/packages/base/src/Internal/Modular.hs
index 3b27310..0d906bb 100644
--- a/packages/base/src/Internal/Modular.hs
+++ b/packages/base/src/Internal/Modular.hs
@@ -9,8 +9,8 @@
9{-# LANGUAGE FlexibleInstances #-} 9{-# LANGUAGE FlexibleInstances #-}
10{-# LANGUAGE UndecidableInstances #-} 10{-# LANGUAGE UndecidableInstances #-}
11{-# LANGUAGE GADTs #-} 11{-# LANGUAGE GADTs #-}
12{-# LANGUAGE TypeFamilies #-} 12{-# LANGUAGE TypeFamilies #-}
13 13{-# LANGUAGE TypeOperators #-}
14 14
15{- | 15{- |
16Module : Internal.Modular 16Module : Internal.Modular
@@ -23,7 +23,7 @@ Proof of concept of statically checked modular arithmetic.
23-} 23-}
24 24
25module Internal.Modular( 25module Internal.Modular(
26 Mod 26 Mod, type (./.)
27) where 27) where
28 28
29import Internal.Vector 29import Internal.Vector
@@ -49,6 +49,9 @@ import Data.Complex
49newtype Mod (n :: Nat) t = Mod {unMod:: t} 49newtype Mod (n :: Nat) t = Mod {unMod:: t}
50 deriving (Storable) 50 deriving (Storable)
51 51
52infixr 5 ./.
53type (./.) x n = Mod n x
54
52instance (Integral t, Enum t, KnownNat m) => Enum (Mod m t) 55instance (Integral t, Enum t, KnownNat m) => Enum (Mod m t)
53 where 56 where
54 toEnum = l0 (\m x -> fromIntegral $ x `mod` (fromIntegral m)) 57 toEnum = l0 (\m x -> fromIntegral $ x `mod` (fromIntegral m))