Morphism.hs revision e9458b1a7a19a63aa4c179f9ab20f4d50681c168
c3d42e13d2a7c3749229498658aec34e7e4fd0a0Christian MaederDescription : morphism mapping for FPL
cd7372fc7e6e43c389619f63daa6eb872d9d5b16Christian MaederCopyright : (c) Christian Maeder, DFKI GmbH 2011
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian MaederLicense : GPLv2 or higher, see LICENSE.txt
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian MaederMaintainer : Christian.Maeder@dfki.de
c3d42e13d2a7c3749229498658aec34e7e4fd0a0Christian MaederStability : provisional
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian MaederPortability : portable
99c923311eab71a85f1dcc4785d349609c828da4Christian Maedermodule Fpl.Morphism (FplMor, mapFplSen) where
ce31795240d8fb340bc984b8b35147c955e29afaChristian Maedertype FplMor = Morphism TermExt SignExt (DefMorExt SignExt)
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo TorrinimapFplSen :: FplMor -> FplForm -> FplForm
ce31795240d8fb340bc984b8b35147c955e29afaChristian MaedermapFplSen = mapSen mapTermExt
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo TorrinimapTermExt :: FplMor -> TermExt -> TermExt
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo TorrinimapTermExt m te = let rec = mapTerm mapTermExt m in case te of
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder FixDef fd -> FixDef $ mapFunDef m fd
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo Torrini Case o l r -> Case (rec o) (map (\ (p, t) -> (rec p, rec t)) l) r
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo Torrini Let fd t r -> Let (mapFunDef m fd) (rec t) r
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo Torrini IfThenElse f t e r -> IfThenElse (rec f) (rec t) (rec e) r
120c9bff9059626735fc12b0399dcc9e5a62c345Christian Maeder EqTerm t e r -> EqTerm (rec t) (rec e) r
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo Torrini BoolTerm t -> BoolTerm (rec t)
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo TorrinimapFunDef :: FplMor -> FunDef -> FunDef
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo TorrinimapFunDef m (FunDef i h@(Op_head k vs ms q) at r) =
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo Torrini let nvs = map (mapVars m) vs
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo Torrini nt = fmap (mapTerm mapTermExt m) at
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo Torrini in maybe (FunDef i (Op_head k nvs ms q) nt r)
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo Torrini (\ hty -> let
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo Torrini (j, ty) = mapOpSym (sort_map m) (op_map m) (i, toOpType hty)
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo Torrini in FunDef j (Op_head (opKind ty) nvs (fmap (mapSrt m) ms) q) nt r)
1b0778e21d9b3e71a684ad6e901e8a0e7d57ee1cPaolo Torrini $ headToType h