-----------------------------------------------------------------
-- Autogenerated by Thrift
--
-- DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
--  @generated
-----------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -fno-warn-unused-imports#-}
{-# OPTIONS_GHC -fno-warn-overlapping-patterns#-}
{-# OPTIONS_GHC -fno-warn-incomplete-patterns#-}
{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns#-}
{-# OPTIONS_GHC -fno-warn-incomplete-record-updates#-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Math.Types
       (DivideByZero(DivideByZero),
        QuotRemResponse(QuotRemResponse, quotRemResponse_quot,
                        quotRemResponse_rem))
       where
import qualified Control.DeepSeq as DeepSeq
import qualified Control.Exception as Exception
import qualified Control.Monad as Monad
import qualified Control.Monad.ST.Trans as ST
import qualified Control.Monad.Trans.Class as Trans
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.Types as Aeson
import qualified Data.Default as Default
import qualified Data.HashMap.Strict as HashMap
import qualified Data.Hashable as Hashable
import qualified Data.List as List
import qualified Data.Ord as Ord
import qualified Prelude as Prelude
import qualified Thrift.Binary.Parser as Parser
import qualified Thrift.CodegenTypesOnly as Thrift
import Control.Applicative ((<|>), (*>), (<*))
import Data.Aeson ((.:), (.:?), (.=), (.!=))
import Data.Monoid ((<>))
import Prelude ((.), (<$>), (<*>), (>>=), (==), (/=), (<), (++))

data DivideByZero = DivideByZero{}
                    deriving (Prelude.Eq, Prelude.Show, Prelude.Ord)

instance Aeson.ToJSON DivideByZero where
  toJSON DivideByZero = Aeson.object Prelude.mempty

instance Thrift.ThriftStruct DivideByZero where
  buildStruct _proxy DivideByZero = Thrift.genStruct _proxy []
  parseStruct _proxy
    = ST.runSTT
        (do Prelude.return ()
            let
              _parse _lastId
                = do _fieldBegin <- Trans.lift
                                      (Thrift.parseFieldBegin _proxy _lastId _idMap)
                     case _fieldBegin of
                       Thrift.FieldBegin _type _id _bool -> do case _id of
                                                                 _ -> Trans.lift
                                                                        (Thrift.parseSkip _proxy
                                                                           _type
                                                                           (Prelude.Just _bool))
                                                               _parse _id
                       Thrift.FieldEnd -> do Prelude.pure (DivideByZero)
              _idMap = HashMap.fromList []
            _parse 0)

instance DeepSeq.NFData DivideByZero where
  rnf DivideByZero = ()

instance Default.Default DivideByZero where
  def = DivideByZero

instance Hashable.Hashable DivideByZero where
  hashWithSalt __salt DivideByZero = __salt

instance Exception.Exception DivideByZero

data QuotRemResponse = QuotRemResponse{quotRemResponse_quot ::
                                       Prelude.Int,
                                       quotRemResponse_rem :: Prelude.Int}
                       deriving (Prelude.Eq, Prelude.Show, Prelude.Ord)

instance Aeson.ToJSON QuotRemResponse where
  toJSON (QuotRemResponse __field__quot __field__rem)
    = Aeson.object
        ("quot" .= __field__quot : "rem" .= __field__rem : Prelude.mempty)

instance Thrift.ThriftStruct QuotRemResponse where
  buildStruct _proxy (QuotRemResponse __field__quot __field__rem)
    = Thrift.genStruct _proxy
        (Thrift.genField _proxy "quot" (Thrift.getI64Type _proxy) 1 0
           ((Thrift.genI64 _proxy . Prelude.fromIntegral) __field__quot)
           :
           Thrift.genField _proxy "rem" (Thrift.getI64Type _proxy) 2 1
             ((Thrift.genI64 _proxy . Prelude.fromIntegral) __field__rem)
             : [])
  parseStruct _proxy
    = ST.runSTT
        (do Prelude.return ()
            __field__quot <- ST.newSTRef Default.def
            __field__rem <- ST.newSTRef Default.def
            let
              _parse _lastId
                = do _fieldBegin <- Trans.lift
                                      (Thrift.parseFieldBegin _proxy _lastId _idMap)
                     case _fieldBegin of
                       Thrift.FieldBegin _type _id _bool -> do case _id of
                                                                 1 | _type ==
                                                                       Thrift.getI64Type _proxy
                                                                     ->
                                                                     do !_val <- Trans.lift
                                                                                   (Prelude.fromIntegral
                                                                                      <$>
                                                                                      Thrift.parseI64
                                                                                        _proxy)
                                                                        ST.writeSTRef __field__quot
                                                                          _val
                                                                 2 | _type ==
                                                                       Thrift.getI64Type _proxy
                                                                     ->
                                                                     do !_val <- Trans.lift
                                                                                   (Prelude.fromIntegral
                                                                                      <$>
                                                                                      Thrift.parseI64
                                                                                        _proxy)
                                                                        ST.writeSTRef __field__rem
                                                                          _val
                                                                 _ -> Trans.lift
                                                                        (Thrift.parseSkip _proxy
                                                                           _type
                                                                           (Prelude.Just _bool))
                                                               _parse _id
                       Thrift.FieldEnd -> do !__val__quot <- ST.readSTRef __field__quot
                                             !__val__rem <- ST.readSTRef __field__rem
                                             Prelude.pure (QuotRemResponse __val__quot __val__rem)
              _idMap = HashMap.fromList [("quot", 1), ("rem", 2)]
            _parse 0)

instance DeepSeq.NFData QuotRemResponse where
  rnf (QuotRemResponse __field__quot __field__rem)
    = DeepSeq.rnf __field__quot `Prelude.seq`
        DeepSeq.rnf __field__rem `Prelude.seq` ()

instance Default.Default QuotRemResponse where
  def = QuotRemResponse Default.def Default.def

instance Hashable.Hashable QuotRemResponse where
  hashWithSalt __salt (QuotRemResponse _quot _rem)
    = Hashable.hashWithSalt (Hashable.hashWithSalt __salt _quot) _rem