d29201dd5328b88140ce050100693c501852657dChristian Maeder{-# LANGUAGE TypeSynonymInstances #-}
8cc6f43935309fe1206828425baf6fc35a88d575Martin Kühl{- |
e9458b1a7a19a63aa4c179f9ab20f4d50681c168Jens ElknerModule : ./Maude/Meta/HasName.hs
8cc6f43935309fe1206828425baf6fc35a88d575Martin KühlDescription : Accessing the names of Maude data types
8cc6f43935309fe1206828425baf6fc35a88d575Martin KühlCopyright : (c) Martin Kuehl, Uni Bremen 2008-2009
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuLicense : GPLv2 or higher, see LICENSE.txt
8cc6f43935309fe1206828425baf6fc35a88d575Martin Kühl
8cc6f43935309fe1206828425baf6fc35a88d575Martin KühlMaintainer : mkhl@informatik.uni-bremen.de
8cc6f43935309fe1206828425baf6fc35a88d575Martin KühlStability : experimental
8cc6f43935309fe1206828425baf6fc35a88d575Martin KühlPortability : portable
8cc6f43935309fe1206828425baf6fc35a88d575Martin Kühl
8cc6f43935309fe1206828425baf6fc35a88d575Martin KühlAccessing the names of Maude data types.
8cc6f43935309fe1206828425baf6fc35a88d575Martin Kühl
8cc6f43935309fe1206828425baf6fc35a88d575Martin KühlDefines a type class 'HasName' that lets us access the names of Maude
8cc6f43935309fe1206828425baf6fc35a88d575Martin Kühldata types as 'Qid's.
8cc6f43935309fe1206828425baf6fc35a88d575Martin Kühl
8cc6f43935309fe1206828425baf6fc35a88d575Martin KühlConsider importing "Maude.Meta" instead of this module.
8cc6f43935309fe1206828425baf6fc35a88d575Martin Kühl-}
8cc6f43935309fe1206828425baf6fc35a88d575Martin Kühl
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühlmodule Maude.Meta.HasName (
8cc6f43935309fe1206828425baf6fc35a88d575Martin Kühl -- * The HasName type class
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder HasName (..)
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl) where
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühlimport Maude.AS_Maude
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl
8cc6f43935309fe1206828425baf6fc35a88d575Martin Kühl-- * The HasName type class
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl
8cc6f43935309fe1206828425baf6fc35a88d575Martin Kühl-- | Represents something that has a name (as a 'Qid').
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühlclass HasName a where
8cc6f43935309fe1206828425baf6fc35a88d575Martin Kühl -- | Extract the name of the input.
521e1648b2c66064c41e9ac47bcd510356ed2355Adrián Riesco getName :: a -> Qid
8cc6f43935309fe1206828425baf6fc35a88d575Martin Kühl -- | Map the name of the input.
26b4844ded8825ca5925fb5e9231e663095be699Martin Kühl mapName :: (Qid -> Qid) -> a -> a
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl
8cc6f43935309fe1206828425baf6fc35a88d575Martin Kühl-- * Predefined instances
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl
521e1648b2c66064c41e9ac47bcd510356ed2355Adrián Riescoinstance HasName Qid where
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl getName = id
26b4844ded8825ca5925fb5e9231e663095be699Martin Kühl mapName = id
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühlinstance HasName Type where
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl getName typ = case typ of
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl TypeSort sort -> getName sort
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl TypeKind kind -> getName kind
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl mapName mp typ = case typ of
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl TypeSort sort -> TypeSort $ mapName mp sort
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl TypeKind kind -> TypeKind $ mapName mp kind
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühlinstance HasName Sort where
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl getName (SortId name) = name
26b4844ded8825ca5925fb5e9231e663095be699Martin Kühl mapName mp (SortId name) = SortId $ mp name
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühlinstance HasName Kind where
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl getName (KindId name) = name
26b4844ded8825ca5925fb5e9231e663095be699Martin Kühl mapName mp (KindId name) = KindId $ mp name
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühlinstance HasName ParamId where
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl getName (ParamId name) = name
26b4844ded8825ca5925fb5e9231e663095be699Martin Kühl mapName mp (ParamId name) = ParamId $ mp name
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühlinstance HasName ModId where
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl getName (ModId name) = name
26b4844ded8825ca5925fb5e9231e663095be699Martin Kühl mapName mp (ModId name) = ModId $ mp name
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl
f78126c371b40713bdf7268be1e871198bb6aecfAdrián Riescoinstance HasName ViewId where
f78126c371b40713bdf7268be1e871198bb6aecfAdrián Riesco getName (ViewId name) = name
26b4844ded8825ca5925fb5e9231e663095be699Martin Kühl mapName mp (ViewId name) = ViewId $ mp name
f78126c371b40713bdf7268be1e871198bb6aecfAdrián Riesco
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühlinstance HasName LabelId where
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl getName (LabelId name) = name
26b4844ded8825ca5925fb5e9231e663095be699Martin Kühl mapName mp (LabelId name) = LabelId $ mp name
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühlinstance HasName OpId where
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl getName (OpId name) = name
26b4844ded8825ca5925fb5e9231e663095be699Martin Kühl mapName mp (OpId name) = OpId $ mp name
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühlinstance HasName Operator where
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl getName (Op name _ _ _) = getName name
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl mapName mp (Op name dom cod as) = Op (mapName mp name) dom cod as
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühl
010997ddd12186698c1ebdbcddb63a670552b3c2Adrián Riescoinstance HasName Module where
010997ddd12186698c1ebdbcddb63a670552b3c2Adrián Riesco getName (Module name _ _) = getName name
010997ddd12186698c1ebdbcddb63a670552b3c2Adrián Riesco mapName mp (Module name ps ss) = Module (mapName mp name) ps ss
010997ddd12186698c1ebdbcddb63a670552b3c2Adrián Riesco
1d48923f0ec0898cfc40df24690af805fa4369edAdrián Riescoinstance HasName View where
1d48923f0ec0898cfc40df24690af805fa4369edAdrián Riesco getName (View name _ _ _) = getName name
1d48923f0ec0898cfc40df24690af805fa4369edAdrián Riesco mapName mp (View name from to rnms) = View (mapName mp name) from to rnms
1d48923f0ec0898cfc40df24690af805fa4369edAdrián Riesco
d2020d73b5be74ca654c2facd411387941c6b206Martin Kühlinstance HasName Spec where
ccead401e8728af7734715b70ec4f5c34096b683Martin Kühl getName spec = case spec of
ccead401e8728af7734715b70ec4f5c34096b683Martin Kühl SpecMod modul -> getName modul
ccead401e8728af7734715b70ec4f5c34096b683Martin Kühl SpecTh theory -> getName theory
ccead401e8728af7734715b70ec4f5c34096b683Martin Kühl SpecView view -> getName view
ccead401e8728af7734715b70ec4f5c34096b683Martin Kühl mapName mp spec = case spec of
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder SpecMod modul -> SpecMod $ mapName mp modul
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder SpecTh theory -> SpecTh $ mapName mp theory
ccead401e8728af7734715b70ec4f5c34096b683Martin Kühl SpecView view -> SpecView $ mapName mp view