data Syb = Syb [Dynamic] -- list of [Map val (Set a)]
empty item = Syb $ gmapQ (toDyn . emp item) item
where
emp::x->y->Map.Map y (Set.Set x)
emp x y = Map.empty
insert x (Syb indices) = Syb $ zipWith f indices (gmapQ toDyn x)
where
f dynIndex dynAttr = toDyn $ Map.insert attr
(maybe (Set.singleton x) (Set.insert x) $
Map.lookup attr index) index
where
index = fromJust $ fromDynamic dynIndex
attr = fromJust $ fromDynamic dynAttr
e = empty i where i=i::Test
t1 = Test "foo" 2
c1 = insert t1 e
Which causes the following error (the line numbers are wrong because
there was other code in the original):