HasName.hs revision e9458b1a7a19a63aa4c179f9ab20f4d50681c168
97a9a944b5887e91042b019776c41d5dd74557aferikabele{-# LANGUAGE TypeSynonymInstances #-}
97a9a944b5887e91042b019776c41d5dd74557aferikabele{- |
97a9a944b5887e91042b019776c41d5dd74557aferikabeleModule : ./Maude/Meta/HasName.hs
a945f35eff8b6a88009ce73de6d4c862ce58de3csliveDescription : Accessing the names of Maude data types
a945f35eff8b6a88009ce73de6d4c862ce58de3csliveCopyright : (c) Martin Kuehl, Uni Bremen 2008-2009
a945f35eff8b6a88009ce73de6d4c862ce58de3csliveLicense : GPLv2 or higher, see LICENSE.txt
fe64b2ba25510d8c9dba5560a2d537763566cf40nd
fe64b2ba25510d8c9dba5560a2d537763566cf40ndMaintainer : mkhl@informatik.uni-bremen.de
fe64b2ba25510d8c9dba5560a2d537763566cf40ndStability : experimental
fe64b2ba25510d8c9dba5560a2d537763566cf40ndPortability : portable
fe64b2ba25510d8c9dba5560a2d537763566cf40nd
fe64b2ba25510d8c9dba5560a2d537763566cf40ndAccessing the names of Maude data types.
fe64b2ba25510d8c9dba5560a2d537763566cf40nd
fe64b2ba25510d8c9dba5560a2d537763566cf40ndDefines a type class 'HasName' that lets us access the names of Maude
fe64b2ba25510d8c9dba5560a2d537763566cf40nddata types as 'Qid's.
52fff662005b1866a3ff09bb6c902800c5cc6dedjerenkrantz
fe64b2ba25510d8c9dba5560a2d537763566cf40ndConsider importing "Maude.Meta" instead of this module.
fe64b2ba25510d8c9dba5560a2d537763566cf40nd-}
fe64b2ba25510d8c9dba5560a2d537763566cf40nd
4b5981e276e93df97c34e4da05ca5cf8bbd937dandmodule Maude.Meta.HasName (
fe64b2ba25510d8c9dba5560a2d537763566cf40nd -- * The HasName type class
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd HasName (..)
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd) where
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd
4aa805f8500255bc52a4c03259fe46df10a1d07cyoshikiimport Maude.AS_Maude
d972e4a0688f66b1402473dd9dacfecefa2132a8rbowen
dfb59c684345700bf9186b8d44936f8b1ba082ffgryzor-- * The HasName type class
ecc5150d35c0dc5ee5119c2717e6660fa331abbftakashi
ecc5150d35c0dc5ee5119c2717e6660fa331abbftakashi-- | Represents something that has a name (as a 'Qid').
3b3b7fc78d1f5bfc2769903375050048ff41ff26ndclass HasName a where
fe64b2ba25510d8c9dba5560a2d537763566cf40nd -- | Extract the name of the input.
fe64b2ba25510d8c9dba5560a2d537763566cf40nd getName :: a -> Qid
fe64b2ba25510d8c9dba5560a2d537763566cf40nd -- | Map the name of the input.
fe64b2ba25510d8c9dba5560a2d537763566cf40nd mapName :: (Qid -> Qid) -> a -> a
fe64b2ba25510d8c9dba5560a2d537763566cf40nd
fe64b2ba25510d8c9dba5560a2d537763566cf40nd-- * Predefined instances
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
fe64b2ba25510d8c9dba5560a2d537763566cf40ndinstance HasName Qid where
117c1f888a14e73cdd821dc6c23eb0411144a41cnd getName = id
117c1f888a14e73cdd821dc6c23eb0411144a41cnd mapName = id
4335f1cbf345c91bb996eec540c11ba8ce5d4268nd
117c1f888a14e73cdd821dc6c23eb0411144a41cndinstance HasName Type where
117c1f888a14e73cdd821dc6c23eb0411144a41cnd getName typ = case typ of
117c1f888a14e73cdd821dc6c23eb0411144a41cnd TypeSort sort -> getName sort
117c1f888a14e73cdd821dc6c23eb0411144a41cnd TypeKind kind -> getName kind
9597f440430d8c876dd64f5f78066804650a18ecnoodl mapName mp typ = case typ of
117c1f888a14e73cdd821dc6c23eb0411144a41cnd TypeSort sort -> TypeSort $ mapName mp sort
117c1f888a14e73cdd821dc6c23eb0411144a41cnd TypeKind kind -> TypeKind $ mapName mp kind
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
117c1f888a14e73cdd821dc6c23eb0411144a41cndinstance HasName Sort where
5f86589186bcc15ee13e288a9d73acbeab2409fbdpejesh getName (SortId name) = name
dce2bc31f4940687c7ffabb80570bc37ea7296d8trawick mapName mp (SortId name) = SortId $ mp name
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
117c1f888a14e73cdd821dc6c23eb0411144a41cndinstance HasName Kind where
29b517f9fe7f32a2c3fbdc53e359b6db6f8e8c2csf getName (KindId name) = name
e797af4d7b0cada1278d72d6c8ac77210ef78632minfrin mapName mp (KindId name) = KindId $ mp name
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
117c1f888a14e73cdd821dc6c23eb0411144a41cndinstance HasName ParamId where
117c1f888a14e73cdd821dc6c23eb0411144a41cnd getName (ParamId name) = name
117c1f888a14e73cdd821dc6c23eb0411144a41cnd mapName mp (ParamId name) = ParamId $ mp name
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener
117c1f888a14e73cdd821dc6c23eb0411144a41cndinstance HasName ModId where
3cc4ff86e6cc4cfd7d4ccfc58dedff599091444bnoodl getName (ModId name) = name
117c1f888a14e73cdd821dc6c23eb0411144a41cnd mapName mp (ModId name) = ModId $ mp name
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
117c1f888a14e73cdd821dc6c23eb0411144a41cndinstance HasName ViewId where
117c1f888a14e73cdd821dc6c23eb0411144a41cnd getName (ViewId name) = name
117c1f888a14e73cdd821dc6c23eb0411144a41cnd mapName mp (ViewId name) = ViewId $ mp name
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
117c1f888a14e73cdd821dc6c23eb0411144a41cndinstance HasName LabelId where
6c45910d5394acbc3f20ab3f2615d9ed2b4e6533nd getName (LabelId name) = name
117c1f888a14e73cdd821dc6c23eb0411144a41cnd mapName mp (LabelId name) = LabelId $ mp name
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
117c1f888a14e73cdd821dc6c23eb0411144a41cndinstance HasName OpId where
117c1f888a14e73cdd821dc6c23eb0411144a41cnd getName (OpId name) = name
117c1f888a14e73cdd821dc6c23eb0411144a41cnd mapName mp (OpId name) = OpId $ mp name
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
117c1f888a14e73cdd821dc6c23eb0411144a41cndinstance HasName Operator where
117c1f888a14e73cdd821dc6c23eb0411144a41cnd getName (Op name _ _ _) = getName name
117c1f888a14e73cdd821dc6c23eb0411144a41cnd mapName mp (Op name dom cod as) = Op (mapName mp name) dom cod as
709e3a21ba73b8433462959cd56c773454b34441trawick
117c1f888a14e73cdd821dc6c23eb0411144a41cndinstance HasName Module where
117c1f888a14e73cdd821dc6c23eb0411144a41cnd getName (Module name _ _) = getName name
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen mapName mp (Module name ps ss) = Module (mapName mp name) ps ss
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
117c1f888a14e73cdd821dc6c23eb0411144a41cndinstance HasName View where
117c1f888a14e73cdd821dc6c23eb0411144a41cnd getName (View name _ _ _) = getName name
117c1f888a14e73cdd821dc6c23eb0411144a41cnd mapName mp (View name from to rnms) = View (mapName mp name) from to rnms
e797af4d7b0cada1278d72d6c8ac77210ef78632minfrin
117c1f888a14e73cdd821dc6c23eb0411144a41cndinstance HasName Spec where
117c1f888a14e73cdd821dc6c23eb0411144a41cnd getName spec = case spec of
117c1f888a14e73cdd821dc6c23eb0411144a41cnd SpecMod modul -> getName modul
117c1f888a14e73cdd821dc6c23eb0411144a41cnd SpecTh theory -> getName theory
117c1f888a14e73cdd821dc6c23eb0411144a41cnd SpecView view -> getName view
117c1f888a14e73cdd821dc6c23eb0411144a41cnd mapName mp spec = case spec of
117c1f888a14e73cdd821dc6c23eb0411144a41cnd SpecMod modul -> SpecMod $ mapName mp modul
117c1f888a14e73cdd821dc6c23eb0411144a41cnd SpecTh theory -> SpecTh $ mapName mp theory
117c1f888a14e73cdd821dc6c23eb0411144a41cnd SpecView view -> SpecView $ mapName mp view
117c1f888a14e73cdd821dc6c23eb0411144a41cnd