module TopHybrid.Utilities where
import qualified Data.Map as M
import Data.Maybe
import Control.Monad
import Common.AS_Annotation
import Common.Result
import Common.Id
buildMapFromList :: (Ord a) => [(a, b)] -> M.Map a b
buildMapFromList :: [(a, b)] -> Map a b
buildMapFromList = (Map a b -> (a, b) -> Map a b) -> Map a b -> [(a, b)] -> Map a b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl (\ y :: Map a b
y (x :: a
x, x' :: b
x') -> a -> b -> Map a b -> Map a b
forall k a. Ord k => k -> a -> Map k a -> Map k a
M.insert a
x b
x' Map a b
y) Map a b
forall k a. Map k a
M.empty
msgsList :: [(Int, String)]
msgsList :: [(Int, String)]
msgsList = [(0, String
msg0), (1, String
msg1), (2, String
msg2), (3, String
msg3), (4, String
msg4)]
where
msg0 :: String
msg0 = "Repeated nominals and/or modalities"
msg1 :: String
msg1 = "Nominal not found"
msg2 :: String
msg2 = "No static analyser for this logic"
msg3 :: String
msg3 = "The chosen logic doesn't exist, or " String -> String -> String
forall a. [a] -> [a] -> [a]
++
"isn't available for hybridization"
msg4 :: String
msg4 = "The chosen logic doesn't have a static analyser for formulas"
msgs :: M.Map Int String
msgs :: Map Int String
msgs = [(Int, String)] -> Map Int String
forall a b. Ord a => [(a, b)] -> Map a b
buildMapFromList [(Int, String)]
msgsList
gErr :: String
gErr :: String
gErr = "Unspecific error found"
liftName :: (Monad m) => String -> m a -> m (Named a)
liftName :: String -> m a -> m (Named a)
liftName s :: String
s = (a -> Named a) -> m a -> m (Named a)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ((a -> Named a) -> m a -> m (Named a))
-> (a -> Named a) -> m a -> m (Named a)
forall a b. (a -> b) -> a -> b
$ String -> a -> Named a
forall a s. a -> s -> SenAttr s a
makeNamed String
s
maybeE :: Int -> Maybe a -> a
maybeE :: Int -> Maybe a -> a
maybeE i :: Int
i = a -> Maybe a -> a
forall a. a -> Maybe a -> a
fromMaybe (a -> Maybe a -> a) -> a -> Maybe a -> a
forall a b. (a -> b) -> a -> b
$ String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String -> Maybe String -> String
forall a. a -> Maybe a -> a
fromMaybe String
gErr Maybe String
msg
where msg :: Maybe String
msg = Int -> Map Int String -> Maybe String
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Int
i Map Int String
msgs
mkHint :: a -> String -> Result a
mkHint :: a -> String -> Result a
mkHint a :: a
a s :: String
s = a -> String -> Range -> Result a
forall a. a -> String -> Range -> Result a
hint a
a String
s Range
nullRange