blob: 512140c1b04b9a041ce775832d66d8155c9b884a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import Numeric.Natural
import Control.Exception (evaluate)
newtype Mod a = Mod a deriving (Show)
instance Integral a => Num (Mod a) where
Mod a * Mod b = Mod (a * b `mod` 10000000019)
fromInteger n = Mod (fromInteger n `mod` 10000000019)
main :: IO ()
main = do
-- Should not allocate more compared to Integer
-- _ <- evaluate $ product $ map Mod [(1 :: Integer) .. 1000000]
_ <- evaluate $ product $ map Mod [(1 :: Natural) .. 1000000]
return ()
|