{-# 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 Language_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 import qualified Metadata_Types import qualified Uuid_Types data LanguageIdentification = LanguageIdentification { languageIdentification_uuid :: Uuid_Types.UUID , languageIdentification_metadata :: Metadata_Types.AnnotationMetadata , languageIdentification_languageToProbabilityMap :: (Map.HashMap LT.Text P.Double) } deriving (P.Show,P.Eq,G.Generic,TY.Typeable) instance H.Hashable LanguageIdentification where hashWithSalt salt record = salt `H.hashWithSalt` languageIdentification_uuid record `H.hashWithSalt` languageIdentification_metadata record `H.hashWithSalt` languageIdentification_languageToProbabilityMap record instance QC.Arbitrary LanguageIdentification where arbitrary = M.liftM LanguageIdentification (QC.arbitrary) `M.ap`(QC.arbitrary) `M.ap`(QC.arbitrary) shrink obj | obj == default_LanguageIdentification = [] | P.otherwise = M.catMaybes [ if obj == default_LanguageIdentification{languageIdentification_uuid = languageIdentification_uuid obj} then P.Nothing else P.Just $ default_LanguageIdentification{languageIdentification_uuid = languageIdentification_uuid obj} , if obj == default_LanguageIdentification{languageIdentification_metadata = languageIdentification_metadata obj} then P.Nothing else P.Just $ default_LanguageIdentification{languageIdentification_metadata = languageIdentification_metadata obj} , if obj == default_LanguageIdentification{languageIdentification_languageToProbabilityMap = languageIdentification_languageToProbabilityMap obj} then P.Nothing else P.Just $ default_LanguageIdentification{languageIdentification_languageToProbabilityMap = languageIdentification_languageToProbabilityMap obj} ] from_LanguageIdentification :: LanguageIdentification -> T.ThriftVal from_LanguageIdentification record = T.TStruct $ Map.fromList $ M.catMaybes [ (\_v2 -> P.Just (1, ("uuid",Uuid_Types.from_UUID _v2))) $ languageIdentification_uuid record , (\_v2 -> P.Just (2, ("metadata",Metadata_Types.from_AnnotationMetadata _v2))) $ languageIdentification_metadata record , (\_v2 -> P.Just (3, ("languageToProbabilityMap",T.TMap T.T_STRING T.T_DOUBLE $ P.map (\(_k3,_v4) -> (T.TString $ E.encodeUtf8 _k3, T.TDouble _v4)) $ Map.toList _v2))) $ languageIdentification_languageToProbabilityMap record ] write_LanguageIdentification :: (T.Protocol p, T.Transport t) => p t -> LanguageIdentification -> P.IO () write_LanguageIdentification oprot record = T.writeVal oprot $ from_LanguageIdentification record encode_LanguageIdentification :: (T.Protocol p, T.Transport t) => p t -> LanguageIdentification -> LBS.ByteString encode_LanguageIdentification oprot record = T.serializeVal oprot $ from_LanguageIdentification record to_LanguageIdentification :: T.ThriftVal -> LanguageIdentification to_LanguageIdentification (T.TStruct fields) = LanguageIdentification{ languageIdentification_uuid = P.maybe (P.error "Missing required field: uuid") (\(_,_val6) -> (case _val6 of {T.TStruct _val7 -> (Uuid_Types.to_UUID (T.TStruct _val7)); _ -> P.error "wrong type"})) (Map.lookup (1) fields), languageIdentification_metadata = P.maybe (P.error "Missing required field: metadata") (\(_,_val6) -> (case _val6 of {T.TStruct _val8 -> (Metadata_Types.to_AnnotationMetadata (T.TStruct _val8)); _ -> P.error "wrong type"})) (Map.lookup (2) fields), languageIdentification_languageToProbabilityMap = P.maybe (P.error "Missing required field: languageToProbabilityMap") (\(_,_val6) -> (case _val6 of {T.TMap _ _ _val9 -> (Map.fromList $ P.map (\(_k11,_v10) -> ((case _k11 of {T.TString _val12 -> E.decodeUtf8 _val12; _ -> P.error "wrong type"}),(case _v10 of {T.TDouble _val13 -> _val13; _ -> P.error "wrong type"}))) _val9); _ -> P.error "wrong type"})) (Map.lookup (3) fields) } to_LanguageIdentification _ = P.error "not a struct" read_LanguageIdentification :: (T.Transport t, T.Protocol p) => p t -> P.IO LanguageIdentification read_LanguageIdentification iprot = to_LanguageIdentification <$> T.readVal iprot (T.T_STRUCT typemap_LanguageIdentification) decode_LanguageIdentification :: (T.Protocol p, T.Transport t) => p t -> LBS.ByteString -> LanguageIdentification decode_LanguageIdentification iprot bs = to_LanguageIdentification $ T.deserializeVal iprot (T.T_STRUCT typemap_LanguageIdentification) bs typemap_LanguageIdentification :: T.TypeMap typemap_LanguageIdentification = Map.fromList [(1,("uuid",(T.T_STRUCT Uuid_Types.typemap_UUID))),(2,("metadata",(T.T_STRUCT Metadata_Types.typemap_AnnotationMetadata))),(3,("languageToProbabilityMap",(T.T_MAP T.T_STRING T.T_DOUBLE)))] default_LanguageIdentification :: LanguageIdentification default_LanguageIdentification = LanguageIdentification{ languageIdentification_uuid = Uuid_Types.default_UUID, languageIdentification_metadata = Metadata_Types.default_AnnotationMetadata, languageIdentification_languageToProbabilityMap = Map.empty}