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
|
module ParseWarning where
import ParsePos
data WM a = WM a [Warning]
type Warning = (Pos,String)
getWarnPos :: Warning -> Pos
getWarnPos = fst
setWarnPos :: Warning -> Pos -> Warning
setWarnPos w p = (p,getWarnMsg w)
getWarnMsg :: Warning -> String
getWarnMsg = snd
setWarnMsg :: Warning -> String -> Warning
setWarnMsg w m = (getWarnPos w,m)
returnWM :: a -> [Warning] -> WM a
returnWM x ws = WM x ws
bindWM :: WM a -> (a -> WM b) -> WM b
bindWM (WM x w1) f = let (WM y w2) = (f x) in WM y (w1 ++ w2)
mapWarns :: (Warning -> Warning) -> WM a -> WM a
mapWarns f w = returnWM (discardWarnings w) (map f (getWarnings w))
cleanWM :: a -> WM a
cleanWM x = returnWM x []
singleWM :: a -> Warning -> WM a
singleWM x w = returnWM x [w]
discardWarnings :: WM a -> a
discardWarnings (WM x _) = x
getWarnings :: WM a -> [Warning]
getWarnings (WM _ w) = w
|