diff options
Diffstat (limited to 'packages/base/src/Internal/Modular.hs')
-rw-r--r-- | packages/base/src/Internal/Modular.hs | 9 |
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 | {- | |
16 | Module : Internal.Modular | 16 | Module : Internal.Modular |
@@ -23,7 +23,7 @@ Proof of concept of statically checked modular arithmetic. | |||
23 | -} | 23 | -} |
24 | 24 | ||
25 | module Internal.Modular( | 25 | module Internal.Modular( |
26 | Mod | 26 | Mod, type (./.) |
27 | ) where | 27 | ) where |
28 | 28 | ||
29 | import Internal.Vector | 29 | import Internal.Vector |
@@ -49,6 +49,9 @@ import Data.Complex | |||
49 | newtype Mod (n :: Nat) t = Mod {unMod:: t} | 49 | newtype Mod (n :: Nat) t = Mod {unMod:: t} |
50 | deriving (Storable) | 50 | deriving (Storable) |
51 | 51 | ||
52 | infixr 5 ./. | ||
53 | type (./.) x n = Mod n x | ||
54 | |||
52 | instance (Integral t, Enum t, KnownNat m) => Enum (Mod m t) | 55 | instance (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)) |