module Modal.Utils where
import Common.Id
import Common.AS_Annotation
import CASL.AS_Basic_CASL
import Modal.AS_Modal
import Data.Maybe
getModTermSort :: Id -> Id
getModTermSort :: Id -> Id
getModTermSort rs :: Id
rs = case Id
rs of
Id _ [s :: Id
s] _ -> Id
s
_ -> [Char] -> Id
forall a. HasCallStack => [Char] -> a
error "Modal.Utils.getModTermSort"
addNonEmptyLabel :: String -> Maybe (Named a) -> Maybe (Named a)
addNonEmptyLabel :: [Char] -> Maybe (Named a) -> Maybe (Named a)
addNonEmptyLabel _ Nothing = Maybe (Named a)
forall a. Maybe a
Nothing
addNonEmptyLabel l :: [Char]
l (Just s :: Named a
s)
| [Char] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Char]
l = Named a -> Maybe (Named a)
forall a. a -> Maybe a
Just Named a
s
| Bool
otherwise = Named a -> Maybe (Named a)
forall a. a -> Maybe a
Just (Named a -> Maybe (Named a)) -> Named a -> Maybe (Named a)
forall a b. (a -> b) -> a -> b
$ ([Char] -> [Char]) -> Named a -> Named a
forall a b s. (a -> b) -> SenAttr s a -> SenAttr s b
reName ([Char] -> [Char] -> [Char]
forall a b. a -> b -> a
const [Char]
l) Named a
s
modToTerm :: MODALITY -> Maybe (TERM M_FORMULA)
modToTerm :: MODALITY -> Maybe (TERM M_FORMULA)
modToTerm (Simple_mod _) = Maybe (TERM M_FORMULA)
forall a. Maybe a
Nothing
modToTerm (Term_mod t :: TERM M_FORMULA
t) = TERM M_FORMULA -> Maybe (TERM M_FORMULA)
forall a. a -> Maybe a
Just TERM M_FORMULA
t
addTerm :: ([VAR] -> TERM M_FORMULA -> TERM ())
-> PRED_NAME -> [Maybe (TERM M_FORMULA)] -> [VAR]
-> Maybe (Named CASLFORMULA) -> Maybe (Named CASLFORMULA)
addTerm :: ([VAR] -> TERM M_FORMULA -> TERM ())
-> Id
-> [Maybe (TERM M_FORMULA)]
-> [VAR]
-> Maybe (Named CASLFORMULA)
-> Maybe (Named CASLFORMULA)
addTerm _ _ mTerms :: [Maybe (TERM M_FORMULA)]
mTerms _ nCaslFrm :: Maybe (Named CASLFORMULA)
nCaslFrm
| [TERM M_FORMULA] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([Maybe (TERM M_FORMULA)] -> [TERM M_FORMULA]
forall a. [Maybe a] -> [a]
catMaybes [Maybe (TERM M_FORMULA)]
mTerms) = Maybe (Named CASLFORMULA)
nCaslFrm
| Bool
otherwise = Maybe (Named CASLFORMULA)
nCaslFrm