HasLabels.hs revision 521e1648b2c66064c41e9ac47bcd510356ed2355
ca010363454de207082dfaa4b753531ce2a34551Christian Maedermodule Maude.Meta.HasLabels (
ca010363454de207082dfaa4b753531ce2a34551Christian Maeder HasLabels(..)
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder) where
49fc18b4bb1d4a8d3ec05e0cffd5f0475b289592Christian Maeder
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian Maederimport Maude.AS_Maude
ca010363454de207082dfaa4b753531ce2a34551Christian Maeder
3f69b6948966979163bdfe8331c38833d5d90ecdChristian Maederimport Maude.Meta.HasName
ca010363454de207082dfaa4b753531ce2a34551Christian Maeder
49fc18b4bb1d4a8d3ec05e0cffd5f0475b289592Christian Maederimport Data.Set (Set)
ca010363454de207082dfaa4b753531ce2a34551Christian Maederimport Data.Map (Map)
79d11c2e3ad242ebb241f5d4a5e98a674c0b986fChristian Maederimport qualified Data.Set as Set
ca010363454de207082dfaa4b753531ce2a34551Christian Maeder
ca010363454de207082dfaa4b753531ce2a34551Christian Maeder
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maederclass HasLabels a where
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder getLabels :: a -> Set Qid
1eb10c0c30323eed3cc21082fd242cd09a612dc5Christian Maeder mapLabels :: Map Qid Qid -> a -> a
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maederinstance (HasLabels a) => HasLabels [a] where
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder getLabels = Set.unions . map getLabels
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder mapLabels = map . mapLabels
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder
ca010363454de207082dfaa4b753531ce2a34551Christian Maederinstance (HasLabels a, HasLabels b) => HasLabels (a, b) where
ca010363454de207082dfaa4b753531ce2a34551Christian Maeder getLabels (a, b) = Set.union (getLabels a) (getLabels b)
ca010363454de207082dfaa4b753531ce2a34551Christian Maeder mapLabels mp (a, b) = (mapLabels mp a, mapLabels mp b)
ca010363454de207082dfaa4b753531ce2a34551Christian Maeder
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maederinstance (HasLabels a, HasLabels b, HasLabels c) => HasLabels (a, b, c) where
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder getLabels (a, b, c) = Set.union (getLabels a) (getLabels (b, c))
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder mapLabels mp (a, b, c) = (mapLabels mp a, mapLabels mp b, mapLabels mp c)
4561227a776bdf0ab679b19fb92f1eaaed8786f7Christian Maeder
c438c79d00fc438f99627e612498744bdc0d0c89Christian Maederinstance (Ord a, HasLabels a) => HasLabels (Set a) where
23f8d286586ff38a9e73052b2c7c04c62c5c638fChristian Maeder getLabels = Set.fold (Set.union . getLabels) Set.empty
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder mapLabels = Set.map . mapLabels
962036a37b92afb04ac0725cde9f20e599c04c5fChristian Maeder
e68f45f355ed9d4026ee9baff5aa75aa7c911cc2Christian Maeder
ad270004874ce1d0697fb30d7309f180553bb315Christian Maederinstance HasLabels StmntAttr where
fc8c6570c7b4ee13f375eb607bed2290438573bfChristian Maeder getLabels attr = case attr of
83cc27e4ca7cf1a4bb5f4a8df17d3e6d44e6f1eaChristian Maeder Label name -> Set.singleton (getName name)
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder _ -> Set.empty
028f19cdb09d52bb2fd207399b6fa874540d1670Christian Maeder mapLabels mp attr = case attr of
975642b989852fc24119c59cf40bc1af653608ffChristian Maeder Label name -> Label $ mapName mp name
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder _ -> attr
83cc27e4ca7cf1a4bb5f4a8df17d3e6d44e6f1eaChristian Maeder
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maederinstance HasLabels Equation where
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder getLabels (Eq _ _ _ as) = getLabels as
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder mapLabels mp (Eq t1 t2 cs as) = Eq t1 t2 cs (mapLabels mp as)
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder
fc8c6570c7b4ee13f375eb607bed2290438573bfChristian Maeder
83cc27e4ca7cf1a4bb5f4a8df17d3e6d44e6f1eaChristian Maederinstance HasLabels Membership where
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder getLabels (Mb _ _ _ as) = getLabels as
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder mapLabels mp (Mb ts ss cs as) = Mb ts ss cs (mapLabels mp as)
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder
49fc18b4bb1d4a8d3ec05e0cffd5f0475b289592Christian Maeder
53301de22afd7190981b363b57c48df86fcb50f7Christian Maederinstance HasLabels Rule where
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder getLabels (Rl _ _ _ as) = getLabels as
da2b959c50c95309d8eb8b24174249c2847e74b5Christian Maeder mapLabels mp (Rl t1 t2 cs as) = Rl t1 t2 cs (mapLabels mp as)
da2b959c50c95309d8eb8b24174249c2847e74b5Christian Maeder