fea627e6caa8f996eea41ee2c30973fd0b00bf7c
[ghc.git] / compiler / utils / FastStringEnv.hs
1 {-
2 %
3 % (c) The University of Glasgow 2006
4 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
5 %
6 \section[FastStringEnv]{@FastStringEnv@: FastString environments}
7 -}
8
9 module FastStringEnv (
10 -- * FastString environments (maps)
11 FastStringEnv,
12
13 -- ** Manipulating these environments
14 mkFsEnv,
15 emptyFsEnv, unitFsEnv, fsEnvElts,
16 extendFsEnv_C, extendFsEnv_Acc, extendFsEnv,
17 extendFsEnvList, extendFsEnvList_C,
18 filterFsEnv,
19 plusFsEnv, plusFsEnv_C, alterFsEnv,
20 lookupFsEnv, lookupFsEnv_NF, delFromFsEnv, delListFromFsEnv,
21 elemFsEnv, mapFsEnv,
22 ) where
23
24 import UniqFM
25 import Maybes
26 import FastString
27
28
29 type FastStringEnv a = UniqFM a -- Domain is FastString
30
31 emptyFsEnv :: FastStringEnv a
32 mkFsEnv :: [(FastString,a)] -> FastStringEnv a
33 fsEnvElts :: FastStringEnv a -> [a]
34 alterFsEnv :: (Maybe a-> Maybe a) -> FastStringEnv a -> FastString -> FastStringEnv a
35 extendFsEnv_C :: (a->a->a) -> FastStringEnv a -> FastString -> a -> FastStringEnv a
36 extendFsEnv_Acc :: (a->b->b) -> (a->b) -> FastStringEnv b -> FastString -> a -> FastStringEnv b
37 extendFsEnv :: FastStringEnv a -> FastString -> a -> FastStringEnv a
38 plusFsEnv :: FastStringEnv a -> FastStringEnv a -> FastStringEnv a
39 plusFsEnv_C :: (a->a->a) -> FastStringEnv a -> FastStringEnv a -> FastStringEnv a
40 extendFsEnvList :: FastStringEnv a -> [(FastString,a)] -> FastStringEnv a
41 extendFsEnvList_C :: (a->a->a) -> FastStringEnv a -> [(FastString,a)] -> FastStringEnv a
42 delFromFsEnv :: FastStringEnv a -> FastString -> FastStringEnv a
43 delListFromFsEnv :: FastStringEnv a -> [FastString] -> FastStringEnv a
44 elemFsEnv :: FastString -> FastStringEnv a -> Bool
45 unitFsEnv :: FastString -> a -> FastStringEnv a
46 lookupFsEnv :: FastStringEnv a -> FastString -> Maybe a
47 lookupFsEnv_NF :: FastStringEnv a -> FastString -> a
48 filterFsEnv :: (elt -> Bool) -> FastStringEnv elt -> FastStringEnv elt
49 mapFsEnv :: (elt1 -> elt2) -> FastStringEnv elt1 -> FastStringEnv elt2
50
51 fsEnvElts x = eltsUFM x
52 emptyFsEnv = emptyUFM
53 unitFsEnv x y = unitUFM x y
54 extendFsEnv x y z = addToUFM x y z
55 extendFsEnvList x l = addListToUFM x l
56 lookupFsEnv x y = lookupUFM x y
57 alterFsEnv = alterUFM
58 mkFsEnv l = listToUFM l
59 elemFsEnv x y = elemUFM x y
60 plusFsEnv x y = plusUFM x y
61 plusFsEnv_C f x y = plusUFM_C f x y
62 extendFsEnv_C f x y z = addToUFM_C f x y z
63 mapFsEnv f x = mapUFM f x
64 extendFsEnv_Acc x y z a b = addToUFM_Acc x y z a b
65 extendFsEnvList_C x y z = addListToUFM_C x y z
66 delFromFsEnv x y = delFromUFM x y
67 delListFromFsEnv x y = delListFromUFM x y
68 filterFsEnv x y = filterUFM x y
69
70 lookupFsEnv_NF env n = expectJust "lookupFsEnv_NF" (lookupFsEnv env n)