{-# 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.9.3) -- -- -- -- DO NOT EDIT UNLESS YOU ARE SURE YOU KNOW WHAT YOU ARE DOING -- ----------------------------------------------------------------- module Audio_Types 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 data Sound = Sound { sound_wav :: P.Maybe LBS.ByteString , sound_mp3 :: P.Maybe LBS.ByteString , sound_sph :: P.Maybe LBS.ByteString , sound_path :: P.Maybe LT.Text } deriving (P.Show,P.Eq,G.Generic,TY.Typeable) instance H.Hashable Sound where hashWithSalt salt record = salt `H.hashWithSalt` sound_wav record `H.hashWithSalt` sound_mp3 record `H.hashWithSalt` sound_sph record `H.hashWithSalt` sound_path record instance QC.Arbitrary Sound where arbitrary = M.liftM Sound (M.liftM P.Just QC.arbitrary) `M.ap`(M.liftM P.Just QC.arbitrary) `M.ap`(M.liftM P.Just QC.arbitrary) `M.ap`(M.liftM P.Just QC.arbitrary) shrink obj | obj == default_Sound = [] | P.otherwise = M.catMaybes [ if obj == default_Sound{sound_wav = sound_wav obj} then P.Nothing else P.Just $ default_Sound{sound_wav = sound_wav obj} , if obj == default_Sound{sound_mp3 = sound_mp3 obj} then P.Nothing else P.Just $ default_Sound{sound_mp3 = sound_mp3 obj} , if obj == default_Sound{sound_sph = sound_sph obj} then P.Nothing else P.Just $ default_Sound{sound_sph = sound_sph obj} , if obj == default_Sound{sound_path = sound_path obj} then P.Nothing else P.Just $ default_Sound{sound_path = sound_path obj} ] from_Sound :: Sound -> T.ThriftVal from_Sound record = T.TStruct $ Map.fromList $ M.catMaybes [ (\_v2 -> (1, ("wav",T.TString _v2))) <$> sound_wav record , (\_v2 -> (2, ("mp3",T.TString _v2))) <$> sound_mp3 record , (\_v2 -> (3, ("sph",T.TString _v2))) <$> sound_sph record , (\_v2 -> (4, ("path",T.TString $ E.encodeUtf8 _v2))) <$> sound_path record ] write_Sound :: (T.Protocol p, T.Transport t) => p t -> Sound -> P.IO () write_Sound oprot record = T.writeVal oprot $ from_Sound record encode_Sound :: (T.Protocol p, T.Transport t) => p t -> Sound -> LBS.ByteString encode_Sound oprot record = T.serializeVal oprot $ from_Sound record to_Sound :: T.ThriftVal -> Sound to_Sound (T.TStruct fields) = Sound{ sound_wav = P.maybe (P.Nothing) (\(_,_val4) -> P.Just (case _val4 of {T.TString _val5 -> _val5; _ -> P.error "wrong type"})) (Map.lookup (1) fields), sound_mp3 = P.maybe (P.Nothing) (\(_,_val4) -> P.Just (case _val4 of {T.TString _val6 -> _val6; _ -> P.error "wrong type"})) (Map.lookup (2) fields), sound_sph = P.maybe (P.Nothing) (\(_,_val4) -> P.Just (case _val4 of {T.TString _val7 -> _val7; _ -> P.error "wrong type"})) (Map.lookup (3) fields), sound_path = P.maybe (P.Nothing) (\(_,_val4) -> P.Just (case _val4 of {T.TString _val8 -> E.decodeUtf8 _val8; _ -> P.error "wrong type"})) (Map.lookup (4) fields) } to_Sound _ = P.error "not a struct" read_Sound :: (T.Transport t, T.Protocol p) => p t -> P.IO Sound read_Sound iprot = to_Sound <$> T.readVal iprot (T.T_STRUCT typemap_Sound) decode_Sound :: (T.Protocol p, T.Transport t) => p t -> LBS.ByteString -> Sound decode_Sound iprot bs = to_Sound $ T.deserializeVal iprot (T.T_STRUCT typemap_Sound) bs typemap_Sound :: T.TypeMap typemap_Sound = Map.fromList [(1,("wav",T.T_STRING)),(2,("mp3",T.T_STRING)),(3,("sph",T.T_STRING)),(4,("path",T.T_STRING))] default_Sound :: Sound default_Sound = Sound{ sound_wav = P.Nothing, sound_mp3 = P.Nothing, sound_sph = P.Nothing, sound_path = P.Nothing}