{-# LANGUAGE CPP, TypeFamilies, DeriveDataTypeable #-} module PGIP.Output.Translations ( formatTranslations ) where import PGIP.Output.Formatting import PGIP.Output.Mime import Logic.Comorphism (AnyComorphism) import Proofs.AbstractState (G_prover) import Common.Json (ppJson, asJson) import Common.ToXml (asXml) import Common.Utils import Text.XML.Light (ppTopElement) import Data.Data type TranslationsFormatter = [(G_prover, AnyComorphism)] -> (String, String) formatTranslations :: Maybe String -> TranslationsFormatter formatTranslations :: Maybe String -> TranslationsFormatter formatTranslations format :: Maybe String format comorphisms :: [(G_prover, AnyComorphism)] comorphisms = case Maybe String format of Just "json" -> (String, String) formatAsJSON _ -> (String, String) formatAsXML where convertedTranslations :: Translations convertedTranslations :: Translations convertedTranslations = Translations :: [String] -> Translations Translations { translations :: [String] translations = [String] -> [String] forall a. Ord a => [a] -> [a] nubOrd ([String] -> [String]) -> [String] -> [String] forall a b. (a -> b) -> a -> b $ ((G_prover, AnyComorphism) -> String) -> [(G_prover, AnyComorphism)] -> [String] forall a b. (a -> b) -> [a] -> [b] map (AnyComorphism -> String showComorph (AnyComorphism -> String) -> ((G_prover, AnyComorphism) -> AnyComorphism) -> (G_prover, AnyComorphism) -> String forall b c a. (b -> c) -> (a -> b) -> a -> c . (G_prover, AnyComorphism) -> AnyComorphism forall a b. (a, b) -> b snd) [(G_prover, AnyComorphism)] comorphisms } formatAsJSON :: (String, String) formatAsJSON :: (String, String) formatAsJSON = (String jsonC, Json -> String ppJson (Json -> String) -> Json -> String forall a b. (a -> b) -> a -> b $ Translations -> Json forall a. ToJson a => a -> Json asJson Translations convertedTranslations) formatAsXML :: (String, String) formatAsXML :: (String, String) formatAsXML = (String xmlC, Element -> String ppTopElement (Element -> String) -> Element -> String forall a b. (a -> b) -> a -> b $ Translations -> Element forall a. ToXml a => a -> Element asXml Translations convertedTranslations) data Translations = Translations { Translations -> [String] translations :: [String] } deriving (Int -> Translations -> ShowS [Translations] -> ShowS Translations -> String (Int -> Translations -> ShowS) -> (Translations -> String) -> ([Translations] -> ShowS) -> Show Translations forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Translations] -> ShowS $cshowList :: [Translations] -> ShowS show :: Translations -> String $cshow :: Translations -> String showsPrec :: Int -> Translations -> ShowS $cshowsPrec :: Int -> Translations -> ShowS Show, Typeable, Typeable Translations Constr DataType Typeable Translations => (forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Translations -> c Translations) -> (forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Translations) -> (Translations -> Constr) -> (Translations -> DataType) -> (forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Translations)) -> (forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Translations)) -> ((forall b. Data b => b -> b) -> Translations -> Translations) -> (forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Translations -> r) -> (forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Translations -> r) -> (forall u. (forall d. Data d => d -> u) -> Translations -> [u]) -> (forall u. Int -> (forall d. Data d => d -> u) -> Translations -> u) -> (forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> Translations -> m Translations) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Translations -> m Translations) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Translations -> m Translations) -> Data Translations Translations -> Constr Translations -> DataType (forall b. Data b => b -> b) -> Translations -> Translations (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Translations -> c Translations (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Translations forall a. Typeable a => (forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> a -> c a) -> (forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c a) -> (a -> Constr) -> (a -> DataType) -> (forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c a)) -> (forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a)) -> ((forall b. Data b => b -> b) -> a -> a) -> (forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r) -> (forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r) -> (forall u. (forall d. Data d => d -> u) -> a -> [u]) -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u) -> (forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> a -> m a) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> a -> m a) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> a -> m a) -> Data a forall u. Int -> (forall d. Data d => d -> u) -> Translations -> u forall u. (forall d. Data d => d -> u) -> Translations -> [u] forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Translations -> r forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Translations -> r forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> Translations -> m Translations forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Translations -> m Translations forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Translations forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Translations -> c Translations forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Translations) forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Translations) $cTranslations :: Constr $tTranslations :: DataType gmapMo :: (forall d. Data d => d -> m d) -> Translations -> m Translations $cgmapMo :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Translations -> m Translations gmapMp :: (forall d. Data d => d -> m d) -> Translations -> m Translations $cgmapMp :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Translations -> m Translations gmapM :: (forall d. Data d => d -> m d) -> Translations -> m Translations $cgmapM :: forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> Translations -> m Translations gmapQi :: Int -> (forall d. Data d => d -> u) -> Translations -> u $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Translations -> u gmapQ :: (forall d. Data d => d -> u) -> Translations -> [u] $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Translations -> [u] gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Translations -> r $cgmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Translations -> r gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Translations -> r $cgmapQl :: forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Translations -> r gmapT :: (forall b. Data b => b -> b) -> Translations -> Translations $cgmapT :: (forall b. Data b => b -> b) -> Translations -> Translations dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Translations) $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Translations) dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Translations) $cdataCast1 :: forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Translations) dataTypeOf :: Translations -> DataType $cdataTypeOf :: Translations -> DataType toConstr :: Translations -> Constr $ctoConstr :: Translations -> Constr gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Translations $cgunfold :: forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Translations gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Translations -> c Translations $cgfoldl :: forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Translations -> c Translations $cp1Data :: Typeable Translations Data)