{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -fno-warn-missing-fields #-} {-# OPTIONS_GHC -fno-warn-missing-signatures #-} {-# OPTIONS_GHC -fno-warn-name-shadowing #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-unused-matches #-} ----------------------------------------------------------------- -- Autogenerated by Thrift Compiler (0.10.0) -- -- -- -- DO NOT EDIT UNLESS YOU ARE SURE YOU KNOW WHAT YOU ARE DOING -- ----------------------------------------------------------------- module Data.Concrete.Autogen.StoreCommunicationService where import Prelude (($), (.), (>>=), (==), (++)) import qualified Prelude as P import qualified Control.Exception as X import qualified Control.Monad as M ( liftM, ap, when ) import Data.Functor ( (<$>) ) import qualified Data.ByteString.Lazy as LBS import qualified Data.Hashable as H import qualified Data.Int as I import qualified Data.Maybe as M (catMaybes) import qualified Data.Text.Lazy.Encoding as E ( decodeUtf8, encodeUtf8 ) import qualified Data.Text.Lazy as LT import qualified GHC.Generics as G (Generic) import qualified Data.Typeable as TY ( Typeable ) import qualified Data.HashMap.Strict as Map import qualified Data.HashSet as Set import qualified Data.Vector as Vector import qualified Test.QuickCheck.Arbitrary as QC ( Arbitrary(..) ) import qualified Test.QuickCheck as QC ( elements ) import qualified Thrift as T import qualified Thrift.Types as T import qualified Thrift.Arbitraries as T import Data.Concrete.Autogen.Communication_Types as Communication_Types import Data.Concrete.Autogen.Services_Types as Services_Types import qualified Data.Concrete.Autogen.Service as Service import Data.Concrete.Autogen.Access_Types as Access_Types import qualified Data.Concrete.Autogen.StoreCommunicationService_Iface as Iface -- HELPER FUNCTIONS AND STRUCTURES -- data Store_args = Store_args { store_args_communication :: Communication_Types.Communication } deriving (P.Show,P.Eq,G.Generic,TY.Typeable) instance H.Hashable Store_args where hashWithSalt salt record = salt `H.hashWithSalt` store_args_communication record instance QC.Arbitrary Store_args where arbitrary = M.liftM Store_args (QC.arbitrary) shrink obj | obj == default_Store_args = [] | P.otherwise = M.catMaybes [ if obj == default_Store_args{store_args_communication = store_args_communication obj} then P.Nothing else P.Just $ default_Store_args{store_args_communication = store_args_communication obj} ] from_Store_args :: Store_args -> T.ThriftVal from_Store_args record = T.TStruct $ Map.fromList $ M.catMaybes [ (\_v66 -> P.Just (1, ("communication",Communication_Types.from_Communication _v66))) $ store_args_communication record ] write_Store_args :: (T.Protocol p, T.Transport t) => p t -> Store_args -> P.IO () write_Store_args oprot record = T.writeVal oprot $ from_Store_args record encode_Store_args :: (T.Protocol p, T.Transport t) => p t -> Store_args -> LBS.ByteString encode_Store_args oprot record = T.serializeVal oprot $ from_Store_args record to_Store_args :: T.ThriftVal -> Store_args to_Store_args (T.TStruct fields) = Store_args{ store_args_communication = P.maybe (store_args_communication default_Store_args) (\(_,_val68) -> (case _val68 of {T.TStruct _val69 -> (Communication_Types.to_Communication (T.TStruct _val69)); _ -> P.error "wrong type"})) (Map.lookup (1) fields) } to_Store_args _ = P.error "not a struct" read_Store_args :: (T.Transport t, T.Protocol p) => p t -> P.IO Store_args read_Store_args iprot = to_Store_args <$> T.readVal iprot (T.T_STRUCT typemap_Store_args) decode_Store_args :: (T.Protocol p, T.Transport t) => p t -> LBS.ByteString -> Store_args decode_Store_args iprot bs = to_Store_args $ T.deserializeVal iprot (T.T_STRUCT typemap_Store_args) bs typemap_Store_args :: T.TypeMap typemap_Store_args = Map.fromList [(1,("communication",(T.T_STRUCT Communication_Types.typemap_Communication)))] default_Store_args :: Store_args default_Store_args = Store_args{ store_args_communication = Communication_Types.default_Communication} data Store_result = Store_result { store_result_ex :: P.Maybe Services_Types.ServicesException } deriving (P.Show,P.Eq,G.Generic,TY.Typeable) instance H.Hashable Store_result where hashWithSalt salt record = salt `H.hashWithSalt` store_result_ex record instance QC.Arbitrary Store_result where arbitrary = M.liftM Store_result (M.liftM P.Just QC.arbitrary) shrink obj | obj == default_Store_result = [] | P.otherwise = M.catMaybes [ if obj == default_Store_result{store_result_ex = store_result_ex obj} then P.Nothing else P.Just $ default_Store_result{store_result_ex = store_result_ex obj} ] from_Store_result :: Store_result -> T.ThriftVal from_Store_result record = T.TStruct $ Map.fromList (let exns = M.catMaybes [ (\_v72 -> (1, ("ex",Services_Types.from_ServicesException _v72))) <$> store_result_ex record] in if P.not (P.null exns) then exns else M.catMaybes [ (\_v72 -> (1, ("ex",Services_Types.from_ServicesException _v72))) <$> store_result_ex record ] ) write_Store_result :: (T.Protocol p, T.Transport t) => p t -> Store_result -> P.IO () write_Store_result oprot record = T.writeVal oprot $ from_Store_result record encode_Store_result :: (T.Protocol p, T.Transport t) => p t -> Store_result -> LBS.ByteString encode_Store_result oprot record = T.serializeVal oprot $ from_Store_result record to_Store_result :: T.ThriftVal -> Store_result to_Store_result (T.TStruct fields) = Store_result{ store_result_ex = P.maybe (P.Nothing) (\(_,_val74) -> P.Just (case _val74 of {T.TStruct _val75 -> (Services_Types.to_ServicesException (T.TStruct _val75)); _ -> P.error "wrong type"})) (Map.lookup (1) fields) } to_Store_result _ = P.error "not a struct" read_Store_result :: (T.Transport t, T.Protocol p) => p t -> P.IO Store_result read_Store_result iprot = to_Store_result <$> T.readVal iprot (T.T_STRUCT typemap_Store_result) decode_Store_result :: (T.Protocol p, T.Transport t) => p t -> LBS.ByteString -> Store_result decode_Store_result iprot bs = to_Store_result $ T.deserializeVal iprot (T.T_STRUCT typemap_Store_result) bs typemap_Store_result :: T.TypeMap typemap_Store_result = Map.fromList [(1,("ex",(T.T_STRUCT Services_Types.typemap_ServicesException)))] default_Store_result :: Store_result default_Store_result = Store_result{ store_result_ex = P.Nothing} process_store (seqid, iprot, oprot, handler) = do args <- read_Store_args iprot (X.catch (X.catch (do Iface.store handler (store_args_communication args) let res = default_Store_result T.writeMessageBegin oprot ("store", T.M_REPLY, seqid) write_Store_result oprot res T.writeMessageEnd oprot T.tFlush (T.getTransport oprot)) (\e -> do let res = default_Store_result{store_result_ex = P.Just e} T.writeMessageBegin oprot ("store", T.M_REPLY, seqid) write_Store_result oprot res T.writeMessageEnd oprot T.tFlush (T.getTransport oprot))) ((\_ -> do T.writeMessageBegin oprot ("store", T.M_EXCEPTION, seqid) T.writeAppExn oprot (T.AppExn T.AE_UNKNOWN "") T.writeMessageEnd oprot T.tFlush (T.getTransport oprot)) :: X.SomeException -> P.IO ())) proc_ handler (iprot,oprot) (name,typ,seqid) = case name of "store" -> process_store (seqid,iprot,oprot,handler) _ -> Service.proc_ handler (iprot,oprot) (name,typ,seqid) process handler (iprot, oprot) = do (name, typ, seqid) <- T.readMessageBegin iprot proc_ handler (iprot,oprot) (name,typ,seqid) T.readMessageEnd iprot P.return P.True