1 import "Prelude" as Prelude
3 import "MList" as MList
5 type T a b = MMap.T a (MList.T b)
7 add :: MMap.T a (MList.T b) -> a -> b -> <Proc> ()
8 add m k v = match MMap.get m k with
9 Just l -> MList.add l v
10 Nothing -> Prelude.ignore (MMap.put m k (MList.singleton v))
12 get :: MMap.T a (MList.T b) -> a -> <Proc> [b]
13 get m k = match MMap.get m k with
14 Just l -> MList.freeze l
17 indexBy :: (v -> <e> k) -> [v] -> <Proc,e> MMap.T k (MList.T v)
19 result = MMap.createC (Prelude.length l)
20 Prelude.iter (\v -> add result (f v) v) l