{-# LANGUAGE FlexibleContexts #-} module PGIP.GraphQL.Resolver.SignatureMorphism (resolve) where import PGIP.GraphQL.Resolver.ToResult import PGIP.GraphQL.Result as GraphQLResult import PGIP.GraphQL.Result.LanguageMapping as GraphQLResultLanguageMapping import PGIP.GraphQL.Result.LogicMapping as GraphQLResultLogicMapping import PGIP.GraphQL.Result.Mapping as GraphQLResultMapping import PGIP.GraphQL.Result.SymbolMapping as GraphQLResultSymbolMapping import PGIP.Shared import Driver.Options import Persistence.Database import Persistence.Utils import Persistence.Schema as DatabaseSchema import Database.Esqueleto import Control.Monad.IO.Class (MonadIO (..)) import Control.Monad.Fail () resolve :: HetcatsOpts -> Cache -> Int -> IO (Maybe GraphQLResult.Result) resolve :: HetcatsOpts -> Cache -> Int -> IO (Maybe Result) resolve opts :: HetcatsOpts opts _ idVar :: Int idVar = DBConfig -> DBMonad (NoLoggingT IO) (Maybe Result) -> IO (Maybe Result) forall (m :: * -> *) a. (MonadIO m, MonadBaseControl IO m, MonadUnliftIO m, MonadFail m) => DBConfig -> DBMonad (NoLoggingT m) a -> m a onDatabase (HetcatsOpts -> DBConfig databaseConfig HetcatsOpts opts) (DBMonad (NoLoggingT IO) (Maybe Result) -> IO (Maybe Result)) -> DBMonad (NoLoggingT IO) (Maybe Result) -> IO (Maybe Result) forall a b. (a -> b) -> a -> b $ Int -> DBMonad (NoLoggingT IO) (Maybe Result) forall (m :: * -> *). (MonadIO m, MonadFail m) => Int -> DBMonad m (Maybe Result) resolveDB Int idVar resolveDB :: (MonadIO m, MonadFail m) => Int -> DBMonad m (Maybe GraphQLResult.Result) resolveDB :: Int -> DBMonad m (Maybe Result) resolveDB idVar :: Int idVar = do [(Entity SignatureMorphism, Entity Signature, Entity Signature)] signatureMorphismL <- SqlQuery (SqlExpr (Entity SignatureMorphism), SqlExpr (Entity Signature), SqlExpr (Entity Signature)) -> ReaderT SqlBackend m [(Entity SignatureMorphism, Entity Signature, Entity Signature)] forall a r (m :: * -> *). (SqlSelect a r, MonadIO m) => SqlQuery a -> SqlReadT m [r] select (SqlQuery (SqlExpr (Entity SignatureMorphism), SqlExpr (Entity Signature), SqlExpr (Entity Signature)) -> ReaderT SqlBackend m [(Entity SignatureMorphism, Entity Signature, Entity Signature)]) -> SqlQuery (SqlExpr (Entity SignatureMorphism), SqlExpr (Entity Signature), SqlExpr (Entity Signature)) -> ReaderT SqlBackend m [(Entity SignatureMorphism, Entity Signature, Entity Signature)] forall a b. (a -> b) -> a -> b $ (InnerJoin (InnerJoin (SqlExpr (Entity SignatureMorphism)) (SqlExpr (Entity Signature))) (SqlExpr (Entity Signature)) -> SqlQuery (SqlExpr (Entity SignatureMorphism), SqlExpr (Entity Signature), SqlExpr (Entity Signature))) -> SqlQuery (SqlExpr (Entity SignatureMorphism), SqlExpr (Entity Signature), SqlExpr (Entity Signature)) forall a b. From a => (a -> SqlQuery b) -> SqlQuery b from ((InnerJoin (InnerJoin (SqlExpr (Entity SignatureMorphism)) (SqlExpr (Entity Signature))) (SqlExpr (Entity Signature)) -> SqlQuery (SqlExpr (Entity SignatureMorphism), SqlExpr (Entity Signature), SqlExpr (Entity Signature))) -> SqlQuery (SqlExpr (Entity SignatureMorphism), SqlExpr (Entity Signature), SqlExpr (Entity Signature))) -> (InnerJoin (InnerJoin (SqlExpr (Entity SignatureMorphism)) (SqlExpr (Entity Signature))) (SqlExpr (Entity Signature)) -> SqlQuery (SqlExpr (Entity SignatureMorphism), SqlExpr (Entity Signature), SqlExpr (Entity Signature))) -> SqlQuery (SqlExpr (Entity SignatureMorphism), SqlExpr (Entity Signature), SqlExpr (Entity Signature)) forall a b. (a -> b) -> a -> b $ \(signature_morphisms :: SqlExpr (Entity SignatureMorphism) signature_morphisms `InnerJoin` signaturesSource :: SqlExpr (Entity Signature) signaturesSource `InnerJoin` signaturesTarget :: SqlExpr (Entity Signature) signaturesTarget) -> do SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Entity Signature) signaturesTarget SqlExpr (Entity Signature) -> EntityField Signature (Key Signature) -> SqlExpr (Value (Key Signature)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Signature (Key Signature) forall typ. (typ ~ Key Signature) => EntityField Signature typ SignatureId SqlExpr (Value (Key Signature)) -> SqlExpr (Value (Key Signature)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity SignatureMorphism) signature_morphisms SqlExpr (Entity SignatureMorphism) -> EntityField SignatureMorphism (Key Signature) -> SqlExpr (Value (Key Signature)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField SignatureMorphism (Key Signature) forall typ. (typ ~ Key Signature) => EntityField SignatureMorphism typ SignatureMorphismTargetId) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Entity Signature) signaturesSource SqlExpr (Entity Signature) -> EntityField Signature (Key Signature) -> SqlExpr (Value (Key Signature)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Signature (Key Signature) forall typ. (typ ~ Key Signature) => EntityField Signature typ SignatureId SqlExpr (Value (Key Signature)) -> SqlExpr (Value (Key Signature)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity SignatureMorphism) signature_morphisms SqlExpr (Entity SignatureMorphism) -> EntityField SignatureMorphism (Key Signature) -> SqlExpr (Value (Key Signature)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField SignatureMorphism (Key Signature) forall typ. (typ ~ Key Signature) => EntityField SignatureMorphism typ SignatureMorphismSourceId) SqlExpr (Value Bool) -> SqlQuery () where_ (SqlExpr (Entity SignatureMorphism) signature_morphisms SqlExpr (Entity SignatureMorphism) -> EntityField SignatureMorphism (Key SignatureMorphism) -> SqlExpr (Value (Key SignatureMorphism)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField SignatureMorphism (Key SignatureMorphism) forall typ. (typ ~ Key SignatureMorphism) => EntityField SignatureMorphism typ SignatureMorphismId SqlExpr (Value (Key SignatureMorphism)) -> SqlExpr (Value (Key SignatureMorphism)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. Key SignatureMorphism -> SqlExpr (Value (Key SignatureMorphism)) forall typ. PersistField typ => typ -> SqlExpr (Value typ) val (Int64 -> Key SignatureMorphism forall record. ToBackendKey SqlBackend record => Int64 -> Key record toSqlKey (Int64 -> Key SignatureMorphism) -> Int64 -> Key SignatureMorphism forall a b. (a -> b) -> a -> b $ Int -> Int64 forall a b. (Integral a, Num b) => a -> b fromIntegral Int idVar)) (SqlExpr (Entity SignatureMorphism), SqlExpr (Entity Signature), SqlExpr (Entity Signature)) -> SqlQuery (SqlExpr (Entity SignatureMorphism), SqlExpr (Entity Signature), SqlExpr (Entity Signature)) forall (m :: * -> *) a. Monad m => a -> m a return (SqlExpr (Entity SignatureMorphism) signature_morphisms, SqlExpr (Entity Signature) signaturesSource, SqlExpr (Entity Signature) signaturesTarget) case [(Entity SignatureMorphism, Entity Signature, Entity Signature)] signatureMorphismL of [] -> Maybe Result -> DBMonad m (Maybe Result) forall (m :: * -> *) a. Monad m => a -> m a return Maybe Result forall a. Maybe a Nothing (signatureMorphismEntity :: Entity SignatureMorphism signatureMorphismEntity@(Entity signatureMorphismKey :: Key SignatureMorphism signatureMorphismKey _), signatureSource :: Entity Signature signatureSource, signatureTarget :: Entity Signature signatureTarget) : _ -> do LogicMapping logicMappingResult <- Key SignatureMorphism -> DBMonad m LogicMapping forall (m :: * -> *). (MonadIO m, MonadFail m) => Key SignatureMorphism -> DBMonad m LogicMapping getLogicMappingResult Key SignatureMorphism signatureMorphismKey [Mapping] mappingResults <- Key SignatureMorphism -> DBMonad m [Mapping] forall (m :: * -> *). MonadIO m => Key SignatureMorphism -> DBMonad m [Mapping] getMappingsResults Key SignatureMorphism signatureMorphismKey [SymbolMapping] symbolMappingResults <- Key SignatureMorphism -> DBMonad m [SymbolMapping] forall (m :: * -> *). MonadIO m => Key SignatureMorphism -> DBMonad m [SymbolMapping] getSymbolMappingResults Key SignatureMorphism signatureMorphismKey Maybe Result -> DBMonad m (Maybe Result) forall (m :: * -> *) a. Monad m => a -> m a return (Maybe Result -> DBMonad m (Maybe Result)) -> Maybe Result -> DBMonad m (Maybe Result) forall a b. (a -> b) -> a -> b $ Result -> Maybe Result forall a. a -> Maybe a Just (Result -> Maybe Result) -> Result -> Maybe Result forall a b. (a -> b) -> a -> b $ SignatureMorphism -> Result GraphQLResult.SignatureMorphismResult (SignatureMorphism -> Result) -> SignatureMorphism -> Result forall a b. (a -> b) -> a -> b $ Entity SignatureMorphism -> Entity Signature -> Entity Signature -> LogicMapping -> [Mapping] -> [SymbolMapping] -> SignatureMorphism signatureMorphismToResult Entity SignatureMorphism signatureMorphismEntity Entity Signature signatureSource Entity Signature signatureTarget LogicMapping logicMappingResult [Mapping] mappingResults [SymbolMapping] symbolMappingResults getLogicMappingResult :: (MonadIO m, MonadFail m) => SignatureMorphismId -> DBMonad m GraphQLResultLogicMapping.LogicMapping getLogicMappingResult :: Key SignatureMorphism -> DBMonad m LogicMapping getLogicMappingResult signatureMorphismKey :: Key SignatureMorphism signatureMorphismKey = do (logicMappingEntity :: Entity LogicMapping logicMappingEntity@(Entity logicMappingKey :: Key LogicMapping logicMappingKey _), logicSource :: Entity Logic logicSource, logicTarget :: Entity Logic logicTarget) : _ <- SqlQuery (SqlExpr (Entity LogicMapping), SqlExpr (Entity Logic), SqlExpr (Entity Logic)) -> ReaderT SqlBackend m [(Entity LogicMapping, Entity Logic, Entity Logic)] forall a r (m :: * -> *). (SqlSelect a r, MonadIO m) => SqlQuery a -> SqlReadT m [r] select (SqlQuery (SqlExpr (Entity LogicMapping), SqlExpr (Entity Logic), SqlExpr (Entity Logic)) -> ReaderT SqlBackend m [(Entity LogicMapping, Entity Logic, Entity Logic)]) -> SqlQuery (SqlExpr (Entity LogicMapping), SqlExpr (Entity Logic), SqlExpr (Entity Logic)) -> ReaderT SqlBackend m [(Entity LogicMapping, Entity Logic, Entity Logic)] forall a b. (a -> b) -> a -> b $ (InnerJoin (InnerJoin (InnerJoin (SqlExpr (Entity SignatureMorphism)) (SqlExpr (Entity LogicMapping))) (SqlExpr (Entity Logic))) (SqlExpr (Entity Logic)) -> SqlQuery (SqlExpr (Entity LogicMapping), SqlExpr (Entity Logic), SqlExpr (Entity Logic))) -> SqlQuery (SqlExpr (Entity LogicMapping), SqlExpr (Entity Logic), SqlExpr (Entity Logic)) forall a b. From a => (a -> SqlQuery b) -> SqlQuery b from ((InnerJoin (InnerJoin (InnerJoin (SqlExpr (Entity SignatureMorphism)) (SqlExpr (Entity LogicMapping))) (SqlExpr (Entity Logic))) (SqlExpr (Entity Logic)) -> SqlQuery (SqlExpr (Entity LogicMapping), SqlExpr (Entity Logic), SqlExpr (Entity Logic))) -> SqlQuery (SqlExpr (Entity LogicMapping), SqlExpr (Entity Logic), SqlExpr (Entity Logic))) -> (InnerJoin (InnerJoin (InnerJoin (SqlExpr (Entity SignatureMorphism)) (SqlExpr (Entity LogicMapping))) (SqlExpr (Entity Logic))) (SqlExpr (Entity Logic)) -> SqlQuery (SqlExpr (Entity LogicMapping), SqlExpr (Entity Logic), SqlExpr (Entity Logic))) -> SqlQuery (SqlExpr (Entity LogicMapping), SqlExpr (Entity Logic), SqlExpr (Entity Logic)) forall a b. (a -> b) -> a -> b $ \ (signature_morphisms :: SqlExpr (Entity SignatureMorphism) signature_morphisms `InnerJoin` logic_mappings :: SqlExpr (Entity LogicMapping) logic_mappings `InnerJoin` logicsSource :: SqlExpr (Entity Logic) logicsSource `InnerJoin` logicsTarget :: SqlExpr (Entity Logic) logicsTarget) -> do SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Entity LogicMapping) logic_mappings SqlExpr (Entity LogicMapping) -> EntityField LogicMapping (Key Logic) -> SqlExpr (Value (Key Logic)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField LogicMapping (Key Logic) forall typ. (typ ~ Key Logic) => EntityField LogicMapping typ LogicMappingTargetId SqlExpr (Value (Key Logic)) -> SqlExpr (Value (Key Logic)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity Logic) logicsTarget SqlExpr (Entity Logic) -> EntityField Logic (Key Logic) -> SqlExpr (Value (Key Logic)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Logic (Key Logic) forall typ. (typ ~ Key Logic) => EntityField Logic typ LogicId) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Entity LogicMapping) logic_mappings SqlExpr (Entity LogicMapping) -> EntityField LogicMapping (Key Logic) -> SqlExpr (Value (Key Logic)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField LogicMapping (Key Logic) forall typ. (typ ~ Key Logic) => EntityField LogicMapping typ LogicMappingSourceId SqlExpr (Value (Key Logic)) -> SqlExpr (Value (Key Logic)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity Logic) logicsSource SqlExpr (Entity Logic) -> EntityField Logic (Key Logic) -> SqlExpr (Value (Key Logic)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Logic (Key Logic) forall typ. (typ ~ Key Logic) => EntityField Logic typ LogicId) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Entity SignatureMorphism) signature_morphisms SqlExpr (Entity SignatureMorphism) -> EntityField SignatureMorphism (Key LogicMapping) -> SqlExpr (Value (Key LogicMapping)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField SignatureMorphism (Key LogicMapping) forall typ. (typ ~ Key LogicMapping) => EntityField SignatureMorphism typ SignatureMorphismLogicMappingId SqlExpr (Value (Key LogicMapping)) -> SqlExpr (Value (Key LogicMapping)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity LogicMapping) logic_mappings SqlExpr (Entity LogicMapping) -> EntityField LogicMapping (Key LogicMapping) -> SqlExpr (Value (Key LogicMapping)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField LogicMapping (Key LogicMapping) forall typ. (typ ~ Key LogicMapping) => EntityField LogicMapping typ LogicMappingId) SqlExpr (Value Bool) -> SqlQuery () where_ (SqlExpr (Entity SignatureMorphism) signature_morphisms SqlExpr (Entity SignatureMorphism) -> EntityField SignatureMorphism (Key SignatureMorphism) -> SqlExpr (Value (Key SignatureMorphism)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField SignatureMorphism (Key SignatureMorphism) forall typ. (typ ~ Key SignatureMorphism) => EntityField SignatureMorphism typ SignatureMorphismId SqlExpr (Value (Key SignatureMorphism)) -> SqlExpr (Value (Key SignatureMorphism)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. Key SignatureMorphism -> SqlExpr (Value (Key SignatureMorphism)) forall typ. PersistField typ => typ -> SqlExpr (Value typ) val Key SignatureMorphism signatureMorphismKey) (SqlExpr (Entity LogicMapping), SqlExpr (Entity Logic), SqlExpr (Entity Logic)) -> SqlQuery (SqlExpr (Entity LogicMapping), SqlExpr (Entity Logic), SqlExpr (Entity Logic)) forall (m :: * -> *) a. Monad m => a -> m a return (SqlExpr (Entity LogicMapping) logic_mappings, SqlExpr (Entity Logic) logicsSource, SqlExpr (Entity Logic) logicsTarget) LanguageMapping languageMappingResult <- Key LogicMapping -> DBMonad m LanguageMapping forall (m :: * -> *). (MonadIO m, MonadFail m) => Key LogicMapping -> DBMonad m LanguageMapping getLanguageMapping Key LogicMapping logicMappingKey LogicMapping -> DBMonad m LogicMapping forall (m :: * -> *) a. Monad m => a -> m a return (LogicMapping -> DBMonad m LogicMapping) -> LogicMapping -> DBMonad m LogicMapping forall a b. (a -> b) -> a -> b $ Entity LogicMapping -> Entity Logic -> Entity Logic -> LanguageMapping -> LogicMapping logicMappingToResult Entity LogicMapping logicMappingEntity Entity Logic logicSource Entity Logic logicTarget LanguageMapping languageMappingResult getMappingsResults :: MonadIO m => SignatureMorphismId -> DBMonad m [GraphQLResultMapping.Mapping] getMappingsResults :: Key SignatureMorphism -> DBMonad m [Mapping] getMappingsResults signatureMorphismKey :: Key SignatureMorphism signatureMorphismKey = do [(Entity Mapping, Entity LocIdBase, Entity SignatureMorphism, Maybe (Entity ConservativityStatus), Entity LocIdBase, Entity LocIdBase, Maybe (Entity LocIdBase), Maybe (Entity Language))] mappingData <- SqlQuery (SqlExpr (Entity Mapping), SqlExpr (Entity LocIdBase), SqlExpr (Entity SignatureMorphism), SqlExpr (Maybe (Entity ConservativityStatus)), SqlExpr (Entity LocIdBase), SqlExpr (Entity LocIdBase), SqlExpr (Maybe (Entity LocIdBase)), SqlExpr (Maybe (Entity Language))) -> ReaderT SqlBackend m [(Entity Mapping, Entity LocIdBase, Entity SignatureMorphism, Maybe (Entity ConservativityStatus), Entity LocIdBase, Entity LocIdBase, Maybe (Entity LocIdBase), Maybe (Entity Language))] forall a r (m :: * -> *). (SqlSelect a r, MonadIO m) => SqlQuery a -> SqlReadT m [r] select (SqlQuery (SqlExpr (Entity Mapping), SqlExpr (Entity LocIdBase), SqlExpr (Entity SignatureMorphism), SqlExpr (Maybe (Entity ConservativityStatus)), SqlExpr (Entity LocIdBase), SqlExpr (Entity LocIdBase), SqlExpr (Maybe (Entity LocIdBase)), SqlExpr (Maybe (Entity Language))) -> ReaderT SqlBackend m [(Entity Mapping, Entity LocIdBase, Entity SignatureMorphism, Maybe (Entity ConservativityStatus), Entity LocIdBase, Entity LocIdBase, Maybe (Entity LocIdBase), Maybe (Entity Language))]) -> SqlQuery (SqlExpr (Entity Mapping), SqlExpr (Entity LocIdBase), SqlExpr (Entity SignatureMorphism), SqlExpr (Maybe (Entity ConservativityStatus)), SqlExpr (Entity LocIdBase), SqlExpr (Entity LocIdBase), SqlExpr (Maybe (Entity LocIdBase)), SqlExpr (Maybe (Entity Language))) -> ReaderT SqlBackend m [(Entity Mapping, Entity LocIdBase, Entity SignatureMorphism, Maybe (Entity ConservativityStatus), Entity LocIdBase, Entity LocIdBase, Maybe (Entity LocIdBase), Maybe (Entity Language))] forall a b. (a -> b) -> a -> b $ (LeftOuterJoin (LeftOuterJoin (InnerJoin (InnerJoin (LeftOuterJoin (InnerJoin (InnerJoin (SqlExpr (Entity SignatureMorphism)) (SqlExpr (Entity Mapping))) (SqlExpr (Entity LocIdBase))) (SqlExpr (Maybe (Entity ConservativityStatus)))) (SqlExpr (Entity LocIdBase))) (SqlExpr (Entity LocIdBase))) (SqlExpr (Maybe (Entity LocIdBase)))) (SqlExpr (Maybe (Entity Language))) -> SqlQuery (SqlExpr (Entity Mapping), SqlExpr (Entity LocIdBase), SqlExpr (Entity SignatureMorphism), SqlExpr (Maybe (Entity ConservativityStatus)), SqlExpr (Entity LocIdBase), SqlExpr (Entity LocIdBase), SqlExpr (Maybe (Entity LocIdBase)), SqlExpr (Maybe (Entity Language)))) -> SqlQuery (SqlExpr (Entity Mapping), SqlExpr (Entity LocIdBase), SqlExpr (Entity SignatureMorphism), SqlExpr (Maybe (Entity ConservativityStatus)), SqlExpr (Entity LocIdBase), SqlExpr (Entity LocIdBase), SqlExpr (Maybe (Entity LocIdBase)), SqlExpr (Maybe (Entity Language))) forall a b. From a => (a -> SqlQuery b) -> SqlQuery b from ((LeftOuterJoin (LeftOuterJoin (InnerJoin (InnerJoin (LeftOuterJoin (InnerJoin (InnerJoin (SqlExpr (Entity SignatureMorphism)) (SqlExpr (Entity Mapping))) (SqlExpr (Entity LocIdBase))) (SqlExpr (Maybe (Entity ConservativityStatus)))) (SqlExpr (Entity LocIdBase))) (SqlExpr (Entity LocIdBase))) (SqlExpr (Maybe (Entity LocIdBase)))) (SqlExpr (Maybe (Entity Language))) -> SqlQuery (SqlExpr (Entity Mapping), SqlExpr (Entity LocIdBase), SqlExpr (Entity SignatureMorphism), SqlExpr (Maybe (Entity ConservativityStatus)), SqlExpr (Entity LocIdBase), SqlExpr (Entity LocIdBase), SqlExpr (Maybe (Entity LocIdBase)), SqlExpr (Maybe (Entity Language)))) -> SqlQuery (SqlExpr (Entity Mapping), SqlExpr (Entity LocIdBase), SqlExpr (Entity SignatureMorphism), SqlExpr (Maybe (Entity ConservativityStatus)), SqlExpr (Entity LocIdBase), SqlExpr (Entity LocIdBase), SqlExpr (Maybe (Entity LocIdBase)), SqlExpr (Maybe (Entity Language)))) -> (LeftOuterJoin (LeftOuterJoin (InnerJoin (InnerJoin (LeftOuterJoin (InnerJoin (InnerJoin (SqlExpr (Entity SignatureMorphism)) (SqlExpr (Entity Mapping))) (SqlExpr (Entity LocIdBase))) (SqlExpr (Maybe (Entity ConservativityStatus)))) (SqlExpr (Entity LocIdBase))) (SqlExpr (Entity LocIdBase))) (SqlExpr (Maybe (Entity LocIdBase)))) (SqlExpr (Maybe (Entity Language))) -> SqlQuery (SqlExpr (Entity Mapping), SqlExpr (Entity LocIdBase), SqlExpr (Entity SignatureMorphism), SqlExpr (Maybe (Entity ConservativityStatus)), SqlExpr (Entity LocIdBase), SqlExpr (Entity LocIdBase), SqlExpr (Maybe (Entity LocIdBase)), SqlExpr (Maybe (Entity Language)))) -> SqlQuery (SqlExpr (Entity Mapping), SqlExpr (Entity LocIdBase), SqlExpr (Entity SignatureMorphism), SqlExpr (Maybe (Entity ConservativityStatus)), SqlExpr (Entity LocIdBase), SqlExpr (Entity LocIdBase), SqlExpr (Maybe (Entity LocIdBase)), SqlExpr (Maybe (Entity Language))) forall a b. (a -> b) -> a -> b $ \(signature_morphisms :: SqlExpr (Entity SignatureMorphism) signature_morphisms `InnerJoin` mappingsSql :: SqlExpr (Entity Mapping) mappingsSql `InnerJoin` loc_id_bases :: SqlExpr (Entity LocIdBase) loc_id_bases `LeftOuterJoin` conservativity_statuses :: SqlExpr (Maybe (Entity ConservativityStatus)) conservativity_statuses `InnerJoin` loc_id_basesSource :: SqlExpr (Entity LocIdBase) loc_id_basesSource `InnerJoin` loc_id_basesTarget :: SqlExpr (Entity LocIdBase) loc_id_basesTarget `LeftOuterJoin` loc_id_basesOMS :: SqlExpr (Maybe (Entity LocIdBase)) loc_id_basesOMS `LeftOuterJoin` languages :: SqlExpr (Maybe (Entity Language)) languages) -> do SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Maybe (Entity Language)) languages SqlExpr (Maybe (Entity Language)) -> EntityField Language (Key Language) -> SqlExpr (Value (Maybe (Key Language))) forall val typ. (PersistEntity val, PersistField typ) => SqlExpr (Maybe (Entity val)) -> EntityField val typ -> SqlExpr (Value (Maybe typ)) ?. EntityField Language (Key Language) forall typ. (typ ~ Key Language) => EntityField Language typ LanguageId SqlExpr (Value (Maybe (Key Language))) -> SqlExpr (Value (Maybe (Key Language))) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity Mapping) mappingsSql SqlExpr (Entity Mapping) -> EntityField Mapping (Maybe (Key Language)) -> SqlExpr (Value (Maybe (Key Language))) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Mapping (Maybe (Key Language)) forall typ. (typ ~ Maybe (Key Language)) => EntityField Mapping typ MappingFreenessParameterLanguageId) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Maybe (Entity LocIdBase)) loc_id_basesOMS SqlExpr (Maybe (Entity LocIdBase)) -> EntityField LocIdBase (Key LocIdBase) -> SqlExpr (Value (Maybe (Key LocIdBase))) forall val typ. (PersistEntity val, PersistField typ) => SqlExpr (Maybe (Entity val)) -> EntityField val typ -> SqlExpr (Value (Maybe typ)) ?. EntityField LocIdBase (Key LocIdBase) forall typ. (typ ~ Key LocIdBase) => EntityField LocIdBase typ LocIdBaseId SqlExpr (Value (Maybe (Key LocIdBase))) -> SqlExpr (Value (Maybe (Key LocIdBase))) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity Mapping) mappingsSql SqlExpr (Entity Mapping) -> EntityField Mapping (Maybe (Key LocIdBase)) -> SqlExpr (Value (Maybe (Key LocIdBase))) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Mapping (Maybe (Key LocIdBase)) forall typ. (typ ~ Maybe (Key LocIdBase)) => EntityField Mapping typ MappingFreenessParameterOMSId) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Entity LocIdBase) loc_id_basesTarget SqlExpr (Entity LocIdBase) -> EntityField LocIdBase (Key LocIdBase) -> SqlExpr (Value (Key LocIdBase)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField LocIdBase (Key LocIdBase) forall typ. (typ ~ Key LocIdBase) => EntityField LocIdBase typ LocIdBaseId SqlExpr (Value (Key LocIdBase)) -> SqlExpr (Value (Key LocIdBase)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity Mapping) mappingsSql SqlExpr (Entity Mapping) -> EntityField Mapping (Key LocIdBase) -> SqlExpr (Value (Key LocIdBase)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Mapping (Key LocIdBase) forall typ. (typ ~ Key LocIdBase) => EntityField Mapping typ MappingTargetId) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Entity LocIdBase) loc_id_basesSource SqlExpr (Entity LocIdBase) -> EntityField LocIdBase (Key LocIdBase) -> SqlExpr (Value (Key LocIdBase)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField LocIdBase (Key LocIdBase) forall typ. (typ ~ Key LocIdBase) => EntityField LocIdBase typ LocIdBaseId SqlExpr (Value (Key LocIdBase)) -> SqlExpr (Value (Key LocIdBase)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity Mapping) mappingsSql SqlExpr (Entity Mapping) -> EntityField Mapping (Key LocIdBase) -> SqlExpr (Value (Key LocIdBase)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Mapping (Key LocIdBase) forall typ. (typ ~ Key LocIdBase) => EntityField Mapping typ MappingSourceId) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Maybe (Entity ConservativityStatus)) conservativity_statuses SqlExpr (Maybe (Entity ConservativityStatus)) -> EntityField ConservativityStatus (Key ConservativityStatus) -> SqlExpr (Value (Maybe (Key ConservativityStatus))) forall val typ. (PersistEntity val, PersistField typ) => SqlExpr (Maybe (Entity val)) -> EntityField val typ -> SqlExpr (Value (Maybe typ)) ?. EntityField ConservativityStatus (Key ConservativityStatus) forall typ. (typ ~ Key ConservativityStatus) => EntityField ConservativityStatus typ ConservativityStatusId SqlExpr (Value (Maybe (Key ConservativityStatus))) -> SqlExpr (Value (Maybe (Key ConservativityStatus))) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity Mapping) mappingsSql SqlExpr (Entity Mapping) -> EntityField Mapping (Maybe (Key ConservativityStatus)) -> SqlExpr (Value (Maybe (Key ConservativityStatus))) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Mapping (Maybe (Key ConservativityStatus)) forall typ. (typ ~ Maybe (Key ConservativityStatus)) => EntityField Mapping typ MappingConservativityStatusId) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Entity LocIdBase) loc_id_bases SqlExpr (Entity LocIdBase) -> EntityField LocIdBase (Key LocIdBase) -> SqlExpr (Value (Key LocIdBase)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField LocIdBase (Key LocIdBase) forall typ. (typ ~ Key LocIdBase) => EntityField LocIdBase typ LocIdBaseId SqlExpr (Value (Key LocIdBase)) -> SqlExpr (Value (Key LocIdBase)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Value (Key Mapping)) -> SqlExpr (Value (Key LocIdBase)) forall a b. SqlExpr (Value a) -> SqlExpr (Value b) coerceId (SqlExpr (Entity Mapping) mappingsSql SqlExpr (Entity Mapping) -> EntityField Mapping (Key Mapping) -> SqlExpr (Value (Key Mapping)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Mapping (Key Mapping) forall typ. (typ ~ Key Mapping) => EntityField Mapping typ MappingId)) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Entity Mapping) mappingsSql SqlExpr (Entity Mapping) -> EntityField Mapping (Key SignatureMorphism) -> SqlExpr (Value (Key SignatureMorphism)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Mapping (Key SignatureMorphism) forall typ. (typ ~ Key SignatureMorphism) => EntityField Mapping typ MappingSignatureMorphismId SqlExpr (Value (Key SignatureMorphism)) -> SqlExpr (Value (Key SignatureMorphism)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity SignatureMorphism) signature_morphisms SqlExpr (Entity SignatureMorphism) -> EntityField SignatureMorphism (Key SignatureMorphism) -> SqlExpr (Value (Key SignatureMorphism)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField SignatureMorphism (Key SignatureMorphism) forall typ. (typ ~ Key SignatureMorphism) => EntityField SignatureMorphism typ SignatureMorphismId) SqlExpr (Value Bool) -> SqlQuery () where_ (SqlExpr (Entity SignatureMorphism) signature_morphisms SqlExpr (Entity SignatureMorphism) -> EntityField SignatureMorphism (Key SignatureMorphism) -> SqlExpr (Value (Key SignatureMorphism)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField SignatureMorphism (Key SignatureMorphism) forall typ. (typ ~ Key SignatureMorphism) => EntityField SignatureMorphism typ SignatureMorphismId SqlExpr (Value (Key SignatureMorphism)) -> SqlExpr (Value (Key SignatureMorphism)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. Key SignatureMorphism -> SqlExpr (Value (Key SignatureMorphism)) forall typ. PersistField typ => typ -> SqlExpr (Value typ) val Key SignatureMorphism signatureMorphismKey) (SqlExpr (Entity Mapping), SqlExpr (Entity LocIdBase), SqlExpr (Entity SignatureMorphism), SqlExpr (Maybe (Entity ConservativityStatus)), SqlExpr (Entity LocIdBase), SqlExpr (Entity LocIdBase), SqlExpr (Maybe (Entity LocIdBase)), SqlExpr (Maybe (Entity Language))) -> SqlQuery (SqlExpr (Entity Mapping), SqlExpr (Entity LocIdBase), SqlExpr (Entity SignatureMorphism), SqlExpr (Maybe (Entity ConservativityStatus)), SqlExpr (Entity LocIdBase), SqlExpr (Entity LocIdBase), SqlExpr (Maybe (Entity LocIdBase)), SqlExpr (Maybe (Entity Language))) forall (m :: * -> *) a. Monad m => a -> m a return (SqlExpr (Entity Mapping) mappingsSql, SqlExpr (Entity LocIdBase) loc_id_bases, SqlExpr (Entity SignatureMorphism) signature_morphisms, SqlExpr (Maybe (Entity ConservativityStatus)) conservativity_statuses, SqlExpr (Entity LocIdBase) loc_id_basesSource, SqlExpr (Entity LocIdBase) loc_id_basesTarget, SqlExpr (Maybe (Entity LocIdBase)) loc_id_basesOMS, SqlExpr (Maybe (Entity Language)) languages) [Mapping] -> DBMonad m [Mapping] forall (m :: * -> *) a. Monad m => a -> m a return ([Mapping] -> DBMonad m [Mapping]) -> [Mapping] -> DBMonad m [Mapping] forall a b. (a -> b) -> a -> b $ ((Entity Mapping, Entity LocIdBase, Entity SignatureMorphism, Maybe (Entity ConservativityStatus), Entity LocIdBase, Entity LocIdBase, Maybe (Entity LocIdBase), Maybe (Entity Language)) -> Mapping) -> [(Entity Mapping, Entity LocIdBase, Entity SignatureMorphism, Maybe (Entity ConservativityStatus), Entity LocIdBase, Entity LocIdBase, Maybe (Entity LocIdBase), Maybe (Entity Language))] -> [Mapping] forall a b. (a -> b) -> [a] -> [b] map (\ (mapping :: Entity Mapping mapping, locIdBase :: Entity LocIdBase locIdBase, signatureMorphismEntity :: Entity SignatureMorphism signatureMorphismEntity, conservativityStatusM :: Maybe (Entity ConservativityStatus) conservativityStatusM, locIdBaseSource :: Entity LocIdBase locIdBaseSource, locIdBaseTarget :: Entity LocIdBase locIdBaseTarget, freenesParameterOMSLocIdM :: Maybe (Entity LocIdBase) freenesParameterOMSLocIdM, freenessParameterLanguageM :: Maybe (Entity Language) freenessParameterLanguageM) -> Entity Mapping -> Entity LocIdBase -> Entity SignatureMorphism -> Maybe (Entity ConservativityStatus) -> Entity LocIdBase -> Entity LocIdBase -> Maybe (Entity LocIdBase) -> Maybe (Entity Language) -> Mapping mappingToResult Entity Mapping mapping Entity LocIdBase locIdBase Entity SignatureMorphism signatureMorphismEntity Maybe (Entity ConservativityStatus) conservativityStatusM Entity LocIdBase locIdBaseSource Entity LocIdBase locIdBaseTarget Maybe (Entity LocIdBase) freenesParameterOMSLocIdM Maybe (Entity Language) freenessParameterLanguageM ) [(Entity Mapping, Entity LocIdBase, Entity SignatureMorphism, Maybe (Entity ConservativityStatus), Entity LocIdBase, Entity LocIdBase, Maybe (Entity LocIdBase), Maybe (Entity Language))] mappingData getSymbolMappingResults :: MonadIO m => SignatureMorphismId -> DBMonad m [GraphQLResultSymbolMapping.SymbolMapping] getSymbolMappingResults :: Key SignatureMorphism -> DBMonad m [SymbolMapping] getSymbolMappingResults signatureMorphismKey :: Key SignatureMorphism signatureMorphismKey = do [((Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)), (Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)))] symbolData <- SqlQuery ((SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange))), (SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange)))) -> ReaderT SqlBackend m [((Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)), (Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)))] forall a r (m :: * -> *). (SqlSelect a r, MonadIO m) => SqlQuery a -> SqlReadT m [r] select (SqlQuery ((SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange))), (SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange)))) -> ReaderT SqlBackend m [((Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)), (Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)))]) -> SqlQuery ((SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange))), (SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange)))) -> ReaderT SqlBackend m [((Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)), (Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)))] forall a b. (a -> b) -> a -> b $ (LeftOuterJoin (LeftOuterJoin (InnerJoin (InnerJoin (InnerJoin (InnerJoin (InnerJoin (SqlExpr (Entity SignatureMorphism)) (SqlExpr (Entity SymbolMapping))) (SqlExpr (Entity Symbol))) (SqlExpr (Entity Symbol))) (SqlExpr (Entity LocIdBase))) (SqlExpr (Entity LocIdBase))) (SqlExpr (Maybe (Entity FileRange)))) (SqlExpr (Maybe (Entity FileRange))) -> SqlQuery ((SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange))), (SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange))))) -> SqlQuery ((SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange))), (SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange)))) forall a b. From a => (a -> SqlQuery b) -> SqlQuery b from ((LeftOuterJoin (LeftOuterJoin (InnerJoin (InnerJoin (InnerJoin (InnerJoin (InnerJoin (SqlExpr (Entity SignatureMorphism)) (SqlExpr (Entity SymbolMapping))) (SqlExpr (Entity Symbol))) (SqlExpr (Entity Symbol))) (SqlExpr (Entity LocIdBase))) (SqlExpr (Entity LocIdBase))) (SqlExpr (Maybe (Entity FileRange)))) (SqlExpr (Maybe (Entity FileRange))) -> SqlQuery ((SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange))), (SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange))))) -> SqlQuery ((SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange))), (SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange))))) -> (LeftOuterJoin (LeftOuterJoin (InnerJoin (InnerJoin (InnerJoin (InnerJoin (InnerJoin (SqlExpr (Entity SignatureMorphism)) (SqlExpr (Entity SymbolMapping))) (SqlExpr (Entity Symbol))) (SqlExpr (Entity Symbol))) (SqlExpr (Entity LocIdBase))) (SqlExpr (Entity LocIdBase))) (SqlExpr (Maybe (Entity FileRange)))) (SqlExpr (Maybe (Entity FileRange))) -> SqlQuery ((SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange))), (SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange))))) -> SqlQuery ((SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange))), (SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange)))) forall a b. (a -> b) -> a -> b $ \(signature_morphisms :: SqlExpr (Entity SignatureMorphism) signature_morphisms `InnerJoin` symbol_mappings :: SqlExpr (Entity SymbolMapping) symbol_mappings `InnerJoin` symbolsSource :: SqlExpr (Entity Symbol) symbolsSource `InnerJoin` symbolsTarget :: SqlExpr (Entity Symbol) symbolsTarget `InnerJoin` symbolLoc_id_basesSource :: SqlExpr (Entity LocIdBase) symbolLoc_id_basesSource `InnerJoin` symbolLoc_id_basesTarget :: SqlExpr (Entity LocIdBase) symbolLoc_id_basesTarget `LeftOuterJoin` file_rangesSource :: SqlExpr (Maybe (Entity FileRange)) file_rangesSource `LeftOuterJoin` file_rangesTarget :: SqlExpr (Maybe (Entity FileRange)) file_rangesTarget) -> do SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Maybe (Entity FileRange)) file_rangesTarget SqlExpr (Maybe (Entity FileRange)) -> EntityField FileRange (Key FileRange) -> SqlExpr (Value (Maybe (Key FileRange))) forall val typ. (PersistEntity val, PersistField typ) => SqlExpr (Maybe (Entity val)) -> EntityField val typ -> SqlExpr (Value (Maybe typ)) ?. EntityField FileRange (Key FileRange) forall typ. (typ ~ Key FileRange) => EntityField FileRange typ FileRangeId SqlExpr (Value (Maybe (Key FileRange))) -> SqlExpr (Value (Maybe (Key FileRange))) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity Symbol) symbolsTarget SqlExpr (Entity Symbol) -> EntityField Symbol (Maybe (Key FileRange)) -> SqlExpr (Value (Maybe (Key FileRange))) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Symbol (Maybe (Key FileRange)) forall typ. (typ ~ Maybe (Key FileRange)) => EntityField Symbol typ SymbolFileRangeId) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Maybe (Entity FileRange)) file_rangesSource SqlExpr (Maybe (Entity FileRange)) -> EntityField FileRange (Key FileRange) -> SqlExpr (Value (Maybe (Key FileRange))) forall val typ. (PersistEntity val, PersistField typ) => SqlExpr (Maybe (Entity val)) -> EntityField val typ -> SqlExpr (Value (Maybe typ)) ?. EntityField FileRange (Key FileRange) forall typ. (typ ~ Key FileRange) => EntityField FileRange typ FileRangeId SqlExpr (Value (Maybe (Key FileRange))) -> SqlExpr (Value (Maybe (Key FileRange))) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity Symbol) symbolsSource SqlExpr (Entity Symbol) -> EntityField Symbol (Maybe (Key FileRange)) -> SqlExpr (Value (Maybe (Key FileRange))) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Symbol (Maybe (Key FileRange)) forall typ. (typ ~ Maybe (Key FileRange)) => EntityField Symbol typ SymbolFileRangeId) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Entity LocIdBase) symbolLoc_id_basesTarget SqlExpr (Entity LocIdBase) -> EntityField LocIdBase (Key LocIdBase) -> SqlExpr (Value (Key LocIdBase)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField LocIdBase (Key LocIdBase) forall typ. (typ ~ Key LocIdBase) => EntityField LocIdBase typ LocIdBaseId SqlExpr (Value (Key LocIdBase)) -> SqlExpr (Value (Key LocIdBase)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Value (Key Symbol)) -> SqlExpr (Value (Key LocIdBase)) forall a b. SqlExpr (Value a) -> SqlExpr (Value b) coerceId (SqlExpr (Entity Symbol) symbolsTarget SqlExpr (Entity Symbol) -> EntityField Symbol (Key Symbol) -> SqlExpr (Value (Key Symbol)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Symbol (Key Symbol) forall typ. (typ ~ Key Symbol) => EntityField Symbol typ SymbolId)) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Entity LocIdBase) symbolLoc_id_basesSource SqlExpr (Entity LocIdBase) -> EntityField LocIdBase (Key LocIdBase) -> SqlExpr (Value (Key LocIdBase)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField LocIdBase (Key LocIdBase) forall typ. (typ ~ Key LocIdBase) => EntityField LocIdBase typ LocIdBaseId SqlExpr (Value (Key LocIdBase)) -> SqlExpr (Value (Key LocIdBase)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Value (Key Symbol)) -> SqlExpr (Value (Key LocIdBase)) forall a b. SqlExpr (Value a) -> SqlExpr (Value b) coerceId (SqlExpr (Entity Symbol) symbolsSource SqlExpr (Entity Symbol) -> EntityField Symbol (Key Symbol) -> SqlExpr (Value (Key Symbol)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Symbol (Key Symbol) forall typ. (typ ~ Key Symbol) => EntityField Symbol typ SymbolId)) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Value (Key Symbol)) -> SqlExpr (Value (Key LocIdBase)) forall a b. SqlExpr (Value a) -> SqlExpr (Value b) coerceId (SqlExpr (Entity Symbol) symbolsTarget SqlExpr (Entity Symbol) -> EntityField Symbol (Key Symbol) -> SqlExpr (Value (Key Symbol)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Symbol (Key Symbol) forall typ. (typ ~ Key Symbol) => EntityField Symbol typ SymbolId) SqlExpr (Value (Key LocIdBase)) -> SqlExpr (Value (Key LocIdBase)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity SymbolMapping) symbol_mappings SqlExpr (Entity SymbolMapping) -> EntityField SymbolMapping (Key LocIdBase) -> SqlExpr (Value (Key LocIdBase)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField SymbolMapping (Key LocIdBase) forall typ. (typ ~ Key LocIdBase) => EntityField SymbolMapping typ SymbolMappingTargetId) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Value (Key Symbol)) -> SqlExpr (Value (Key LocIdBase)) forall a b. SqlExpr (Value a) -> SqlExpr (Value b) coerceId (SqlExpr (Entity Symbol) symbolsSource SqlExpr (Entity Symbol) -> EntityField Symbol (Key Symbol) -> SqlExpr (Value (Key Symbol)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Symbol (Key Symbol) forall typ. (typ ~ Key Symbol) => EntityField Symbol typ SymbolId) SqlExpr (Value (Key LocIdBase)) -> SqlExpr (Value (Key LocIdBase)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity SymbolMapping) symbol_mappings SqlExpr (Entity SymbolMapping) -> EntityField SymbolMapping (Key LocIdBase) -> SqlExpr (Value (Key LocIdBase)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField SymbolMapping (Key LocIdBase) forall typ. (typ ~ Key LocIdBase) => EntityField SymbolMapping typ SymbolMappingSourceId) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Entity SignatureMorphism) signature_morphisms SqlExpr (Entity SignatureMorphism) -> EntityField SignatureMorphism (Key SignatureMorphism) -> SqlExpr (Value (Key SignatureMorphism)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField SignatureMorphism (Key SignatureMorphism) forall typ. (typ ~ Key SignatureMorphism) => EntityField SignatureMorphism typ SignatureMorphismId SqlExpr (Value (Key SignatureMorphism)) -> SqlExpr (Value (Key SignatureMorphism)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity SymbolMapping) symbol_mappings SqlExpr (Entity SymbolMapping) -> EntityField SymbolMapping (Key SignatureMorphism) -> SqlExpr (Value (Key SignatureMorphism)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField SymbolMapping (Key SignatureMorphism) forall typ. (typ ~ Key SignatureMorphism) => EntityField SymbolMapping typ SymbolMappingSignatureMorphismId) SqlExpr (Value Bool) -> SqlQuery () where_ (SqlExpr (Entity SignatureMorphism) signature_morphisms SqlExpr (Entity SignatureMorphism) -> EntityField SignatureMorphism (Key SignatureMorphism) -> SqlExpr (Value (Key SignatureMorphism)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField SignatureMorphism (Key SignatureMorphism) forall typ. (typ ~ Key SignatureMorphism) => EntityField SignatureMorphism typ SignatureMorphismId SqlExpr (Value (Key SignatureMorphism)) -> SqlExpr (Value (Key SignatureMorphism)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. Key SignatureMorphism -> SqlExpr (Value (Key SignatureMorphism)) forall typ. PersistField typ => typ -> SqlExpr (Value typ) val Key SignatureMorphism signatureMorphismKey) ((SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange))), (SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange)))) -> SqlQuery ((SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange))), (SqlExpr (Entity LocIdBase), SqlExpr (Entity Symbol), SqlExpr (Maybe (Entity FileRange)))) forall (m :: * -> *) a. Monad m => a -> m a return ( (SqlExpr (Entity LocIdBase) symbolLoc_id_basesSource, SqlExpr (Entity Symbol) symbolsSource, SqlExpr (Maybe (Entity FileRange)) file_rangesSource) , (SqlExpr (Entity LocIdBase) symbolLoc_id_basesTarget, SqlExpr (Entity Symbol) symbolsTarget, SqlExpr (Maybe (Entity FileRange)) file_rangesTarget) ) [SymbolMapping] -> DBMonad m [SymbolMapping] forall (m :: * -> *) a. Monad m => a -> m a return ([SymbolMapping] -> DBMonad m [SymbolMapping]) -> [SymbolMapping] -> DBMonad m [SymbolMapping] forall a b. (a -> b) -> a -> b $ (((Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)), (Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange))) -> SymbolMapping) -> [((Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)), (Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)))] -> [SymbolMapping] forall a b. (a -> b) -> [a] -> [b] map (((Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)) -> (Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)) -> SymbolMapping) -> ((Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)), (Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange))) -> SymbolMapping forall a b c. (a -> b -> c) -> (a, b) -> c uncurry (Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)) -> (Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)) -> SymbolMapping symbolMappingToResult) [((Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)), (Entity LocIdBase, Entity Symbol, Maybe (Entity FileRange)))] symbolData getLanguageMapping :: (MonadIO m, MonadFail m) => LogicMappingId -> DBMonad m GraphQLResultLanguageMapping.LanguageMapping getLanguageMapping :: Key LogicMapping -> DBMonad m LanguageMapping getLanguageMapping logicMappingKey :: Key LogicMapping logicMappingKey = do (languageMappingEntity :: Entity LanguageMapping languageMappingEntity, languageSource :: Entity Language languageSource, languageTarget :: Entity Language languageTarget) : _ <- SqlQuery (SqlExpr (Entity LanguageMapping), SqlExpr (Entity Language), SqlExpr (Entity Language)) -> ReaderT SqlBackend m [(Entity LanguageMapping, Entity Language, Entity Language)] forall a r (m :: * -> *). (SqlSelect a r, MonadIO m) => SqlQuery a -> SqlReadT m [r] select (SqlQuery (SqlExpr (Entity LanguageMapping), SqlExpr (Entity Language), SqlExpr (Entity Language)) -> ReaderT SqlBackend m [(Entity LanguageMapping, Entity Language, Entity Language)]) -> SqlQuery (SqlExpr (Entity LanguageMapping), SqlExpr (Entity Language), SqlExpr (Entity Language)) -> ReaderT SqlBackend m [(Entity LanguageMapping, Entity Language, Entity Language)] forall a b. (a -> b) -> a -> b $ (InnerJoin (InnerJoin (InnerJoin (SqlExpr (Entity LogicMapping)) (SqlExpr (Entity LanguageMapping))) (SqlExpr (Entity Language))) (SqlExpr (Entity Language)) -> SqlQuery (SqlExpr (Entity LanguageMapping), SqlExpr (Entity Language), SqlExpr (Entity Language))) -> SqlQuery (SqlExpr (Entity LanguageMapping), SqlExpr (Entity Language), SqlExpr (Entity Language)) forall a b. From a => (a -> SqlQuery b) -> SqlQuery b from ((InnerJoin (InnerJoin (InnerJoin (SqlExpr (Entity LogicMapping)) (SqlExpr (Entity LanguageMapping))) (SqlExpr (Entity Language))) (SqlExpr (Entity Language)) -> SqlQuery (SqlExpr (Entity LanguageMapping), SqlExpr (Entity Language), SqlExpr (Entity Language))) -> SqlQuery (SqlExpr (Entity LanguageMapping), SqlExpr (Entity Language), SqlExpr (Entity Language))) -> (InnerJoin (InnerJoin (InnerJoin (SqlExpr (Entity LogicMapping)) (SqlExpr (Entity LanguageMapping))) (SqlExpr (Entity Language))) (SqlExpr (Entity Language)) -> SqlQuery (SqlExpr (Entity LanguageMapping), SqlExpr (Entity Language), SqlExpr (Entity Language))) -> SqlQuery (SqlExpr (Entity LanguageMapping), SqlExpr (Entity Language), SqlExpr (Entity Language)) forall a b. (a -> b) -> a -> b $ \(logic_mappings :: SqlExpr (Entity LogicMapping) logic_mappings `InnerJoin` language_mappings :: SqlExpr (Entity LanguageMapping) language_mappings `InnerJoin` languagesSource :: SqlExpr (Entity Language) languagesSource `InnerJoin` languagesTarget :: SqlExpr (Entity Language) languagesTarget) -> do SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Entity LanguageMapping) language_mappings SqlExpr (Entity LanguageMapping) -> EntityField LanguageMapping (Key Language) -> SqlExpr (Value (Key Language)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField LanguageMapping (Key Language) forall typ. (typ ~ Key Language) => EntityField LanguageMapping typ LanguageMappingTargetId SqlExpr (Value (Key Language)) -> SqlExpr (Value (Key Language)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity Language) languagesTarget SqlExpr (Entity Language) -> EntityField Language (Key Language) -> SqlExpr (Value (Key Language)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Language (Key Language) forall typ. (typ ~ Key Language) => EntityField Language typ LanguageId) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Entity LanguageMapping) language_mappings SqlExpr (Entity LanguageMapping) -> EntityField LanguageMapping (Key Language) -> SqlExpr (Value (Key Language)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField LanguageMapping (Key Language) forall typ. (typ ~ Key Language) => EntityField LanguageMapping typ LanguageMappingSourceId SqlExpr (Value (Key Language)) -> SqlExpr (Value (Key Language)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity Language) languagesSource SqlExpr (Entity Language) -> EntityField Language (Key Language) -> SqlExpr (Value (Key Language)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField Language (Key Language) forall typ. (typ ~ Key Language) => EntityField Language typ LanguageId) SqlExpr (Value Bool) -> SqlQuery () on (SqlExpr (Entity LogicMapping) logic_mappings SqlExpr (Entity LogicMapping) -> EntityField LogicMapping (Key LanguageMapping) -> SqlExpr (Value (Key LanguageMapping)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField LogicMapping (Key LanguageMapping) forall typ. (typ ~ Key LanguageMapping) => EntityField LogicMapping typ LogicMappingLanguageMappingId SqlExpr (Value (Key LanguageMapping)) -> SqlExpr (Value (Key LanguageMapping)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. SqlExpr (Entity LanguageMapping) language_mappings SqlExpr (Entity LanguageMapping) -> EntityField LanguageMapping (Key LanguageMapping) -> SqlExpr (Value (Key LanguageMapping)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField LanguageMapping (Key LanguageMapping) forall typ. (typ ~ Key LanguageMapping) => EntityField LanguageMapping typ LanguageMappingId) SqlExpr (Value Bool) -> SqlQuery () where_ (SqlExpr (Entity LogicMapping) logic_mappings SqlExpr (Entity LogicMapping) -> EntityField LogicMapping (Key LogicMapping) -> SqlExpr (Value (Key LogicMapping)) forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) ^. EntityField LogicMapping (Key LogicMapping) forall typ. (typ ~ Key LogicMapping) => EntityField LogicMapping typ LogicMappingId SqlExpr (Value (Key LogicMapping)) -> SqlExpr (Value (Key LogicMapping)) -> SqlExpr (Value Bool) forall typ. PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) ==. Key LogicMapping -> SqlExpr (Value (Key LogicMapping)) forall typ. PersistField typ => typ -> SqlExpr (Value typ) val Key LogicMapping logicMappingKey) (SqlExpr (Entity LanguageMapping), SqlExpr (Entity Language), SqlExpr (Entity Language)) -> SqlQuery (SqlExpr (Entity LanguageMapping), SqlExpr (Entity Language), SqlExpr (Entity Language)) forall (m :: * -> *) a. Monad m => a -> m a return (SqlExpr (Entity LanguageMapping) language_mappings, SqlExpr (Entity Language) languagesSource, SqlExpr (Entity Language) languagesTarget) LanguageMapping -> DBMonad m LanguageMapping forall (m :: * -> *) a. Monad m => a -> m a return (LanguageMapping -> DBMonad m LanguageMapping) -> LanguageMapping -> DBMonad m LanguageMapping forall a b. (a -> b) -> a -> b $ Entity LanguageMapping -> Entity Language -> Entity Language -> LanguageMapping languageMappingToResult Entity LanguageMapping languageMappingEntity Entity Language languageSource Entity Language languageTarget