Morphism.hs revision 8a77240a809197c92c0736c431b4b88947a7bac1
402N/A{- |
402N/AModule : $Header$
402N/ADescription : Symbol related functions for SoftFOL.
402N/ACopyright : (c) Klaus Luettich, Uni Bremen 2007
402N/ALicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
402N/A
402N/AMaintainer : luecke@informatik.uni-bremen.de
402N/AStability : provisional
402N/APortability : portable
402N/A
402N/AFunctions for symbols of SoftFOL.
402N/A-}
402N/A
402N/Amodule SoftFOL.Morphism (symOf, symbolToId) where
402N/A
402N/Aimport SoftFOL.Sign
402N/A
402N/Aimport Common.Id
402N/A
402N/Aimport qualified Data.Set as Set
402N/Aimport qualified Data.Map as Map
402N/A
402N/AsymOf :: Sign -> Set.Set SFSymbol
402N/AsymOf sig =
402N/A let opSymbs = Set.unions $ map toOpSymb $ Map.toList $ funcMap sig
402N/A predSymbs = Set.unions $ map toPredSymb $ Map.toList $ predMap sig
402N/A sortSymbs = Set.map toSortSymb $ Map.keysSet $ sortMap sig
402N/A in Set.unions [opSymbs,predSymbs,sortSymbs]
402N/A
402N/AtoOpSymb :: (SPIdentifier,Set.Set([SPIdentifier], SPIdentifier))
402N/A -> Set.Set SFSymbol
402N/AtoOpSymb (ident,ts) = Set.map toSymb ts
402N/A where toSymb (args,res) =
402N/A SFSymbol { sym_ident = ident
402N/A , sym_type = SFOpType args res}
402N/A
402N/AtoPredSymb :: (SPIdentifier,Set.Set [SPIdentifier]) -> Set.Set SFSymbol
402N/AtoPredSymb (ident,ts) = Set.map toSymb ts
402N/A where toSymb args =
402N/A SFSymbol { sym_ident = ident
402N/A , sym_type = SFPredType args}
402N/A
402N/AtoSortSymb :: SPIdentifier -> SFSymbol
toSortSymb ident = SFSymbol { sym_ident = ident
, sym_type = SFSortType}
symbolToId :: SFSymbol -> Id
symbolToId = mkId . (:[]) . sym_ident