-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCoherence.hs
53 lines (44 loc) · 1.28 KB
/
Coherence.hs
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
41
42
43
44
45
46
47
48
49
50
51
52
53
{-# LANGUAGE ExistentialQuantification #-}
module Main where
import Control.Monad
data Module r v = MkModule
{ zero :: v
, add :: v -> v -> v
, mult :: r -> v -> v
}
data FinGenModule r v = MkFinGenModule
{ underlyingModule :: Module r v
, generatingFamily :: [v]
, coefficients :: v -> [r]
}
data CoherentModule r v = MkCoherentModule
{ underlyingFinGenModule :: FinGenModule r v
, kernel :: [v] -> FinGenModule r v
}
instance (Show v) => Show (FinGenModule r v) where
show m = "fingen<" ++ show (generatingFamily m) ++ ">"
free :: (Num r) => Int -> FinGenModule r [r]
free n = MkFinGenModule
{ underlyingModule = MkModule
{ zero = replicate n 0
, add = liftM2 (+)
, mult = \a -> map (a *)
}
, generatingFamily = map (\i -> replicate i 0 ++ [1] ++ replicate (n-i-1) 0) [0..n-1]
, coefficients = id
}
qq :: CoherentModule Rational Rational
qq = MkCoherentModule
{ underlyingFinGenModule = MkFinGenModule
{ underlyingModule = MkModule
{ zero = 0
, add = (+)
, mult = (*)
}
, generatingFamily = [1]
, coefficients = (:[])
}
, kernel = \xs -> undefined
}
-- Schon erledigt (nur weniger abstrakt):
-- http://hackage.haskell.org/package/constructive-algebra-0.3.0