1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
module A where
import Algebra.Structures.Module
import Algebra.Structures.CommutativeRing
(CommutativeRing, Ring(..), propCommutativeRing)
import Test.QuickCheck
newtype A = A [(Integer,String)]
deriving (Show, Eq, Arbitrary)
instance Ring A where
A xs <+> A ys = A (xs ++ ys)
neg (A a) = A $ [((k),c) | (k,c) <- a]
A x <*> A y = A [b | a <- x, b <- y ]
one = A []
zero = A []
instance CommutativeRing A
instance Module Integer A where
r *> (A as) = A [(r <*> k,c) | (k,c) <- as]
propACommutativeRing :: A -> A -> A -> Property
propACommutativeRing = propCommutativeRing
|