-- GENERATED by C->Haskell Compiler, version 0.28.8 Switcheroo, 25 November 2017 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "./QuantLib/Index/Equity.chs" #-}
module QuantLib.Index.Equity
  (
    -- * Types
    EquityIndex

    -- * Constructors
  , equityIndex
  ) where
import qualified Foreign.C.String as C2HSImp
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.ForeignPtr as C2HSImp
import qualified Foreign.Ptr as C2HSImp


import QuantLib.Internal
import QuantLib.Internal.Type








{-# LINE 18 "./QuantLib/Index/Equity.chs" #-}


{-# LINE 19 "./QuantLib/Index/Equity.chs" #-}


{-# LINE 20 "./QuantLib/Index/Equity.chs" #-}


{-# LINE 21 "./QuantLib/Index/Equity.chs" #-}


{-# LINE 22 "./QuantLib/Index/Equity.chs" #-}


-- |A named equity total-return index, forecasting future fixings from an
-- optional risk-free interest rate curve and dividend curve, and an optional
-- spot 'QuantLib.Quote.Quote' -- today's fixing is used when no spot is given.
-- Historical fixings are added via 'QuantLib.Index.addFixing'. No inspector is bound for
-- currency\/interest curve\/dividend curve\/spot: each is a plain, never-mutated echo of this
-- constructor's own argument, same shape as the currency\/interest\/dividend\/spot fields on
-- 'QuantLib.Index.Commodity.CommodityIndex' -- the caller already holds whatever it passed in.
equityIndex :: (String) -- ^name
 -> (Calendar) -- ^fixingCalendar
 -> (Currency) -> (Maybe (GenYieldTermStructure y1)) -- ^interest
 -> (Maybe (GenYieldTermStructure y2)) -- ^dividend
 -> (Maybe (GenQuote q)) -- ^spot
 -> IO ((EquityIndex))
equityIndex :: forall y1 y2 q.
String
-> Calendar
-> Currency
-> Maybe (GenYieldTermStructure y1)
-> Maybe (GenYieldTermStructure y2)
-> Maybe (GenQuote q)
-> IO EquityIndex
equityIndex String
a1 Calendar
a2 Currency
a3 Maybe (GenYieldTermStructure y1)
a4 Maybe (GenYieldTermStructure y2)
a5 Maybe (GenQuote q)
a6 =
  String -> (CString -> IO EquityIndex) -> IO EquityIndex
forall a. String -> (CString -> IO a) -> IO a
C2HSImp.withCString String
a1 ((CString -> IO EquityIndex) -> IO EquityIndex)
-> (CString -> IO EquityIndex) -> IO EquityIndex
forall a b. (a -> b) -> a -> b
$ \CString
a1' -> 
  Calendar -> (Ptr CCalendar -> IO EquityIndex) -> IO EquityIndex
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a2 ((Ptr CCalendar -> IO EquityIndex) -> IO EquityIndex)
-> (Ptr CCalendar -> IO EquityIndex) -> IO EquityIndex
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a2' -> 
  Currency -> (Ptr CCurrency -> IO EquityIndex) -> IO EquityIndex
forall b. Currency -> (Ptr CCurrency -> IO b) -> IO b
withCurrency Currency
a3 ((Ptr CCurrency -> IO EquityIndex) -> IO EquityIndex)
-> (Ptr CCurrency -> IO EquityIndex) -> IO EquityIndex
forall a b. (a -> b) -> a -> b
$ \Ptr CCurrency
a3' -> 
  Maybe (GenYieldTermStructure y1)
-> (Ptr CYieldTermStructure' -> IO EquityIndex) -> IO EquityIndex
forall y b.
Maybe (GenYieldTermStructure y)
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withMaybeYieldTermStructure Maybe (GenYieldTermStructure y1)
a4 ((Ptr CYieldTermStructure' -> IO EquityIndex) -> IO EquityIndex)
-> (Ptr CYieldTermStructure' -> IO EquityIndex) -> IO EquityIndex
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a4' -> 
  Maybe (GenYieldTermStructure y2)
-> (Ptr CYieldTermStructure' -> IO EquityIndex) -> IO EquityIndex
forall y b.
Maybe (GenYieldTermStructure y)
-> (Ptr CYieldTermStructure' -> IO b) -> IO b
withMaybeYieldTermStructure Maybe (GenYieldTermStructure y2)
a5 ((Ptr CYieldTermStructure' -> IO EquityIndex) -> IO EquityIndex)
-> (Ptr CYieldTermStructure' -> IO EquityIndex) -> IO EquityIndex
forall a b. (a -> b) -> a -> b
$ \Ptr CYieldTermStructure'
a5' -> 
  Maybe (GenQuote q)
-> (Ptr CQuote' -> IO EquityIndex) -> IO EquityIndex
forall q b. Maybe (GenQuote q) -> (Ptr CQuote' -> IO b) -> IO b
withMaybeQuote Maybe (GenQuote q)
a6 ((Ptr CQuote' -> IO EquityIndex) -> IO EquityIndex)
-> (Ptr CQuote' -> IO EquityIndex) -> IO EquityIndex
forall a b. (a -> b) -> a -> b
$ \Ptr CQuote'
a6' -> 
  (Ptr CString -> IO EquityIndex) -> IO EquityIndex
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr CString -> IO EquityIndex) -> IO EquityIndex)
-> (Ptr CString -> IO EquityIndex) -> IO EquityIndex
forall a b. (a -> b) -> a -> b
$ \Ptr CString
a7' -> 
  CString
-> Ptr CCalendar
-> Ptr CCurrency
-> Ptr CYieldTermStructure'
-> Ptr CYieldTermStructure'
-> Ptr CQuote'
-> Ptr CString
-> IO (Ptr CEquityIndex')
equityIndex'_ CString
a1' Ptr CCalendar
a2' Ptr CCurrency
a3' Ptr CYieldTermStructure'
a4' Ptr CYieldTermStructure'
a5' Ptr CQuote'
a6' Ptr CString
a7' IO (Ptr CEquityIndex')
-> (Ptr CEquityIndex' -> IO EquityIndex) -> IO EquityIndex
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CEquityIndex'
res ->
  Ptr CEquityIndex' -> IO EquityIndex
peekEquityIndex Ptr CEquityIndex'
res IO EquityIndex -> (EquityIndex -> IO EquityIndex) -> IO EquityIndex
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \EquityIndex
res' ->
  Ptr CString -> IO ()
errorCheck  Ptr CString
a7'IO () -> IO EquityIndex -> IO EquityIndex
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  EquityIndex -> IO EquityIndex
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (EquityIndex
res')

{-# LINE 37 "./QuantLib/Index/Equity.chs" #-}


-- vim: set ff=unix ts=8 sts=2 sw=2 et:

foreign import ccall safe "QuantLib/Index/Equity.chs.h qlEquityIndex"
  equityIndex'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CQuote')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CEquityIndex'))))))))))