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


{-# LINE 1 "./QuantLib/TermStructure/Inflation.chs" #-}
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
module QuantLib.TermStructure.Inflation
  (
    -- * Types
    GenZeroInflationTermStructure
  , ZeroInflationTermStructure
  , PiecewiseZeroInflationCurve
  , GenYoYInflationTermStructure
  , YoYInflationTermStructure
  , PiecewiseYoYInflationCurve
  , ZeroCouponInflationSwapHelper
  , YearOnYearInflationSwapHelper
  , CPIInterpolationType(..) -- ^re-exported from "QuantLib.Internal.Common"
  , InflationSwapPeriod(..)
    -- ** Seasonality
  , Seasonality(..)

    -- * Constructors
    -- ** Helpers
  , zeroCouponInflationSwapHelper
  , yearOnYearInflationSwapHelper
  , cpiBondHelper
    -- ** Curves
  , piecewiseZeroInflationCurve
  , piecewiseYoyInflationCurve
  , interpolatedYoyInflationCurve
  , interpolatedZeroInflationCurve
    -- ** Conversions
  , asZeroInflationTermStructure
  , asYoyInflationTermStructure

    -- * Inspectors
  , HasHelperUnderlying(..)
  , zeroRate
  , yoyRate
  , HasImpliedQuoteOn(..)
  , HasNodes(..)
  ) where
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.ForeignPtr as C2HSImp
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp


import QuantLib.Internal
import QuantLib.Internal.Type
import QuantLib.Time.Schedule(Frequency(..))
import QuantLib.Internal.Common
import QuantLib.TermStructure(HasHelperUnderlying(..), HasNodes(..))
import Data.List.NonEmpty(NonEmpty, toList)
import QuantLib.TermStructure.Yield(PillarChoice)








{-# LINE 53 "./QuantLib/TermStructure/Inflation.chs" #-}


{-# LINE 54 "./QuantLib/TermStructure/Inflation.chs" #-}


{-# LINE 55 "./QuantLib/TermStructure/Inflation.chs" #-}


{-# LINE 56 "./QuantLib/TermStructure/Inflation.chs" #-}


{-# LINE 57 "./QuantLib/TermStructure/Inflation.chs" #-}


{-# LINE 58 "./QuantLib/TermStructure/Inflation.chs" #-}


{-# LINE 59 "./QuantLib/TermStructure/Inflation.chs" #-}


{-# LINE 60 "./QuantLib/TermStructure/Inflation.chs" #-}


{-# LINE 61 "./QuantLib/TermStructure/Inflation.chs" #-}


{-# LINE 62 "./QuantLib/TermStructure/Inflation.chs" #-}


-- |Which dates an inflation swap helper's swap runs between. 'InflationSwapToMaturity' starts on
-- the evaluation date and moves with it; 'InflationSwapBetweenDates' is fixed. The fixed form also
-- takes its observation-interpolation weight from the start date rather than the maturity.
data InflationSwapPeriod
  = InflationSwapToMaturity
      !Day -- ^maturity
  | InflationSwapBetweenDates
      !Day -- ^startDate
      !Day -- ^endDate

-- |Bootstrap helper for a zero-coupon inflation swap, at the given observation lag and period.
zeroCouponInflationSwapHelper :: GenQuote q -- ^quote
  -> (Word, TimeUnit) -- ^swapObsLag
  -> InflationSwapPeriod
  -> Calendar
  -> BusinessDayConvention -- ^paymentConvention
  -> DayCounter
  -> GenZeroInflationIndex zidx
  -> CPIInterpolationType -- ^observationInterpolation
  -> PillarChoice -- ^pillar
  -> Maybe Day -- ^customPillarDate
  -> IO ZeroCouponInflationSwapHelper
zeroCouponInflationSwapHelper :: forall q zidx.
GenQuote q
-> (Word, TimeUnit)
-> InflationSwapPeriod
-> Calendar
-> BusinessDayConvention
-> DayCounter
-> GenZeroInflationIndex zidx
-> CPIInterpolationType
-> PillarChoice
-> Maybe Day
-> IO ZeroCouponInflationSwapHelper
zeroCouponInflationSwapHelper GenQuote q
quote (Word, TimeUnit)
lag InflationSwapPeriod
period Calendar
cal BusinessDayConvention
conv DayCounter
dc GenZeroInflationIndex zidx
zii CPIInterpolationType
interp PillarChoice
pillar Maybe Day
customPillarDate = case InflationSwapPeriod
period of
  InflationSwapToMaturity Day
m -> GenQuote q
-> (Word, TimeUnit)
-> Day
-> Calendar
-> BusinessDayConvention
-> DayCounter
-> GenZeroInflationIndex zidx
-> CPIInterpolationType
-> PillarChoice
-> Maybe Day
-> IO ZeroCouponInflationSwapHelper
forall q zidx.
GenQuote q
-> (Word, TimeUnit)
-> Day
-> Calendar
-> BusinessDayConvention
-> DayCounter
-> GenZeroInflationIndex zidx
-> CPIInterpolationType
-> PillarChoice
-> Maybe Day
-> IO ZeroCouponInflationSwapHelper
zeroCouponInflationSwapHelperRaw GenQuote q
quote (Word, TimeUnit)
lag Day
m Calendar
cal BusinessDayConvention
conv DayCounter
dc GenZeroInflationIndex zidx
zii CPIInterpolationType
interp PillarChoice
pillar Maybe Day
customPillarDate
  InflationSwapBetweenDates Day
s Day
e ->
    GenQuote q
-> (Word, TimeUnit)
-> Day
-> Day
-> Calendar
-> BusinessDayConvention
-> DayCounter
-> GenZeroInflationIndex zidx
-> CPIInterpolationType
-> PillarChoice
-> Maybe Day
-> IO ZeroCouponInflationSwapHelper
forall q zidx.
GenQuote q
-> (Word, TimeUnit)
-> Day
-> Day
-> Calendar
-> BusinessDayConvention
-> DayCounter
-> GenZeroInflationIndex zidx
-> CPIInterpolationType
-> PillarChoice
-> Maybe Day
-> IO ZeroCouponInflationSwapHelper
zeroCouponInflationSwapHelperBetweenDatesRaw GenQuote q
quote (Word, TimeUnit)
lag Day
s Day
e Calendar
cal BusinessDayConvention
conv DayCounter
dc GenZeroInflationIndex zidx
zii CPIInterpolationType
interp PillarChoice
pillar Maybe Day
customPillarDate

-- |Bootstrap helper for a year-on-year inflation swap. Unlike 'zeroCouponInflationSwapHelper',
-- also needs the nominal discount curve (the YoY swap's fixed/floating legs discount off it).
yearOnYearInflationSwapHelper :: GenQuote q -- ^quote
  -> (Word, TimeUnit) -- ^swapObsLag
  -> InflationSwapPeriod
  -> Calendar
  -> BusinessDayConvention -- ^paymentConvention
  -> DayCounter
  -> GenYoYInflationIndex yidx
  -> CPIInterpolationType -- ^observationInterpolation
  -> GenYieldTermStructure y -- ^nominalTermStructure
  -> PillarChoice -- ^pillar
  -> Maybe Day -- ^customPillarDate
  -> IO YearOnYearInflationSwapHelper
yearOnYearInflationSwapHelper :: forall q yidx y.
GenQuote q
-> (Word, TimeUnit)
-> InflationSwapPeriod
-> Calendar
-> BusinessDayConvention
-> DayCounter
-> GenYoYInflationIndex yidx
-> CPIInterpolationType
-> GenYieldTermStructure y
-> PillarChoice
-> Maybe Day
-> IO YearOnYearInflationSwapHelper
yearOnYearInflationSwapHelper GenQuote q
quote (Word, TimeUnit)
lag InflationSwapPeriod
period Calendar
cal BusinessDayConvention
conv DayCounter
dc GenYoYInflationIndex yidx
yii CPIInterpolationType
interp GenYieldTermStructure y
nominal PillarChoice
pillar Maybe Day
customPillarDate = case InflationSwapPeriod
period of
  InflationSwapToMaturity Day
m -> GenQuote q
-> (Word, TimeUnit)
-> Day
-> Calendar
-> BusinessDayConvention
-> DayCounter
-> GenYoYInflationIndex yidx
-> CPIInterpolationType
-> GenYieldTermStructure y
-> PillarChoice
-> Maybe Day
-> IO YearOnYearInflationSwapHelper
forall q yidx y.
GenQuote q
-> (Word, TimeUnit)
-> Day
-> Calendar
-> BusinessDayConvention
-> DayCounter
-> GenYoYInflationIndex yidx
-> CPIInterpolationType
-> GenYieldTermStructure y
-> PillarChoice
-> Maybe Day
-> IO YearOnYearInflationSwapHelper
yearOnYearInflationSwapHelperRaw GenQuote q
quote (Word, TimeUnit)
lag Day
m Calendar
cal BusinessDayConvention
conv DayCounter
dc GenYoYInflationIndex yidx
yii CPIInterpolationType
interp GenYieldTermStructure y
nominal PillarChoice
pillar Maybe Day
customPillarDate
  InflationSwapBetweenDates Day
s Day
e ->
    GenQuote q
-> (Word, TimeUnit)
-> Day
-> Day
-> Calendar
-> BusinessDayConvention
-> DayCounter
-> GenYoYInflationIndex yidx
-> CPIInterpolationType
-> GenYieldTermStructure y
-> PillarChoice
-> Maybe Day
-> IO YearOnYearInflationSwapHelper
forall q yidx y.
GenQuote q
-> (Word, TimeUnit)
-> Day
-> Day
-> Calendar
-> BusinessDayConvention
-> DayCounter
-> GenYoYInflationIndex yidx
-> CPIInterpolationType
-> GenYieldTermStructure y
-> PillarChoice
-> Maybe Day
-> IO YearOnYearInflationSwapHelper
yearOnYearInflationSwapHelperBetweenDatesRaw GenQuote q
quote (Word, TimeUnit)
lag Day
s Day
e Calendar
cal BusinessDayConvention
conv DayCounter
dc GenYoYInflationIndex yidx
yii CPIInterpolationType
interp GenYieldTermStructure y
nominal PillarChoice
pillar Maybe Day
customPillarDate

-- Raw inflation swap helper bindings; one per 'InflationSwapPeriod' constructor for each helper.
zeroCouponInflationSwapHelperRaw :: (GenQuote q) -- ^quote
 -> ((Word,TimeUnit)) -- ^swapObsLag
 -> (Day) -- ^maturity
 -> (Calendar) -> (BusinessDayConvention) -- ^paymentConvention
 -> (DayCounter) -> (GenZeroInflationIndex zidx) -> (CPIInterpolationType) -- ^observationInterpolation
 -> (PillarChoice) -- ^pillar
 -> (Maybe Day) -- ^customPillarDate
 -> IO ((ZeroCouponInflationSwapHelper))
zeroCouponInflationSwapHelperRaw :: forall q zidx.
GenQuote q
-> (Word, TimeUnit)
-> Day
-> Calendar
-> BusinessDayConvention
-> DayCounter
-> GenZeroInflationIndex zidx
-> CPIInterpolationType
-> PillarChoice
-> Maybe Day
-> IO ZeroCouponInflationSwapHelper
zeroCouponInflationSwapHelperRaw GenQuote q
a1 (Word, TimeUnit)
a2 Day
a3 Calendar
a4 BusinessDayConvention
a5 DayCounter
a6 GenZeroInflationIndex zidx
a7 CPIInterpolationType
a8 PillarChoice
a9 Maybe Day
a10 =
  GenQuote q
-> (Ptr CQuote' -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall q b. GenQuote q -> (Ptr CQuote' -> IO b) -> IO b
withQuote GenQuote q
a1 ((Ptr CQuote' -> IO ZeroCouponInflationSwapHelper)
 -> IO ZeroCouponInflationSwapHelper)
-> (Ptr CQuote' -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CQuote'
a1' -> 
  let {(CInt
a2'1, CInt
a2'2) = (Word, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Word, TimeUnit)
a2} in 
  Day
-> (CInt -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a3 ((CInt -> IO ZeroCouponInflationSwapHelper)
 -> IO ZeroCouponInflationSwapHelper)
-> (CInt -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (a -> b) -> a -> b
$ \CInt
a3' -> 
  Calendar
-> (Ptr CCalendar -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a4 ((Ptr CCalendar -> IO ZeroCouponInflationSwapHelper)
 -> IO ZeroCouponInflationSwapHelper)
-> (Ptr CCalendar -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a4' -> 
  let {a5' :: CInt
a5' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a5} in 
  DayCounter
-> (Ptr CDayCounter -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a6 ((Ptr CDayCounter -> IO ZeroCouponInflationSwapHelper)
 -> IO ZeroCouponInflationSwapHelper)
-> (Ptr CDayCounter -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a6' -> 
  GenZeroInflationIndex zidx
-> (Ptr CZeroInflationIndex' -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall zidx b.
GenZeroInflationIndex zidx
-> (Ptr CZeroInflationIndex' -> IO b) -> IO b
withZeroInflationIndex GenZeroInflationIndex zidx
a7 ((Ptr CZeroInflationIndex' -> IO ZeroCouponInflationSwapHelper)
 -> IO ZeroCouponInflationSwapHelper)
-> (Ptr CZeroInflationIndex' -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CZeroInflationIndex'
a7' -> 
  let {a8' :: CInt
a8' = CPIInterpolationType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC CPIInterpolationType
a8} in 
  let {a9' :: CInt
a9' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (PillarChoice -> Int) -> PillarChoice -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PillarChoice -> Int
forall a. Enum a => a -> Int
fromEnum) PillarChoice
a9} in 
  Maybe Day
-> (CInt -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a10 ((CInt -> IO ZeroCouponInflationSwapHelper)
 -> IO ZeroCouponInflationSwapHelper)
-> (CInt -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (a -> b) -> a -> b
$ \CInt
a10' -> 
  (Ptr (Ptr ()) -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO ZeroCouponInflationSwapHelper)
 -> IO ZeroCouponInflationSwapHelper)
-> (Ptr (Ptr ()) -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a11' -> 
  Ptr CQuote'
-> CInt
-> CInt
-> CInt
-> Ptr CCalendar
-> CInt
-> Ptr CDayCounter
-> Ptr CZeroInflationIndex'
-> CInt
-> CInt
-> CInt
-> Ptr (Ptr ())
-> IO (Ptr CZeroCouponInflationSwapHelper)
zeroCouponInflationSwapHelperRaw'_ Ptr CQuote'
a1' CInt
a2'1  CInt
a2'2 CInt
a3' Ptr CCalendar
a4' CInt
a5' Ptr CDayCounter
a6' Ptr CZeroInflationIndex'
a7' CInt
a8' CInt
a9' CInt
a10' Ptr (Ptr ())
a11' IO (Ptr CZeroCouponInflationSwapHelper)
-> (Ptr CZeroCouponInflationSwapHelper
    -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CZeroCouponInflationSwapHelper
res ->
  Ptr CZeroCouponInflationSwapHelper
-> IO ZeroCouponInflationSwapHelper
peekZeroCouponInflationSwapHelper Ptr CZeroCouponInflationSwapHelper
res IO ZeroCouponInflationSwapHelper
-> (ZeroCouponInflationSwapHelper
    -> IO ZeroCouponInflationSwapHelper)
-> IO ZeroCouponInflationSwapHelper
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ZeroCouponInflationSwapHelper
res' ->
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a11'IO ()
-> IO ZeroCouponInflationSwapHelper
-> IO ZeroCouponInflationSwapHelper
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  ZeroCouponInflationSwapHelper -> IO ZeroCouponInflationSwapHelper
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (ZeroCouponInflationSwapHelper
res')

{-# LINE 121 "./QuantLib/TermStructure/Inflation.chs" #-}


zeroCouponInflationSwapHelperBetweenDatesRaw :: (GenQuote q) -- ^quote
 -> ((Word,TimeUnit)) -- ^swapObsLag
 -> (Day) -- ^startDate
 -> (Day) -- ^endDate
 -> (Calendar) -> (BusinessDayConvention) -- ^paymentConvention
 -> (DayCounter) -> (GenZeroInflationIndex zidx) -> (CPIInterpolationType) -- ^observationInterpolation
 -> (PillarChoice) -- ^pillar
 -> (Maybe Day) -- ^customPillarDate
 -> IO ((ZeroCouponInflationSwapHelper))
zeroCouponInflationSwapHelperBetweenDatesRaw a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
  withQuote a1 $ \a1' -> 
  let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  withDay a3 $ \a3' -> 
  withDay a4 $ \a4' -> 
  withCalendar a5 $ \a5' -> 
  let {a6' = fromEnumC a6} in 
  withDayCounter a7 $ \a7' -> 
  withZeroInflationIndex a8 $ \a8' -> 
  let {a9' = fromEnumC a9} in 
  let {a10' = (fromIntegral . fromEnum) a10} in 
  withMaybeDay a11 $ \a11' -> 
  preErrorCheck $ \a12' -> 
  zeroCouponInflationSwapHelperBetweenDatesRaw'_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
  peekZeroCouponInflationSwapHelper res >>= \res' ->
  errorCheck  a12'>>
  return (res')

{-# LINE 134 "./QuantLib/TermStructure/Inflation.chs" #-}


yearOnYearInflationSwapHelperBetweenDatesRaw :: (GenQuote q) -- ^quote
 -> ((Word,TimeUnit)) -- ^swapObsLag
 -> (Day) -- ^startDate
 -> (Day) -- ^endDate
 -> (Calendar) -> (BusinessDayConvention) -- ^paymentConvention
 -> (DayCounter) -> (GenYoYInflationIndex yidx) -> (CPIInterpolationType) -- ^observationInterpolation
 -> (GenYieldTermStructure y) -- ^nominalTermStructure
 -> (PillarChoice) -- ^pillar
 -> (Maybe Day) -- ^customPillarDate
 -> IO ((YearOnYearInflationSwapHelper))
yearOnYearInflationSwapHelperBetweenDatesRaw a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
  withQuote a1 $ \a1' -> 
  let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  withDay a3 $ \a3' -> 
  withDay a4 $ \a4' -> 
  withCalendar a5 $ \a5' -> 
  let {a6' = fromEnumC a6} in 
  withDayCounter a7 $ \a7' -> 
  withYoYInflationIndex a8 $ \a8' -> 
  let {a9' = fromEnumC a9} in 
  withYieldTermStructure a10 $ \a10' -> 
  let {a11' = (fromIntegral . fromEnum) a11} in 
  withMaybeDay a12 $ \a12' -> 
  preErrorCheck $ \a13' -> 
  yearOnYearInflationSwapHelperBetweenDatesRaw'_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' a13' >>= \res ->
  peekYearOnYearInflationSwapHelper res >>= \res' ->
  errorCheck  a13'>>
  return (res')

{-# LINE 148 "./QuantLib/TermStructure/Inflation.chs" #-}


yearOnYearInflationSwapHelperRaw :: (GenQuote q) -- ^quote
 -> ((Word,TimeUnit)) -- ^swapObsLag
 -> (Day) -- ^maturity
 -> (Calendar) -> (BusinessDayConvention) -- ^paymentConvention
 -> (DayCounter) -> (GenYoYInflationIndex yidx) -> (CPIInterpolationType) -- ^observationInterpolation
 -> (GenYieldTermStructure y) -- ^nominalTermStructure
 -> (PillarChoice) -- ^pillar
 -> (Maybe Day) -- ^customPillarDate
 -> IO ((YearOnYearInflationSwapHelper))
yearOnYearInflationSwapHelperRaw a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
  withQuote a1 $ \a1' -> 
  let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  withDay a3 $ \a3' -> 
  withCalendar a4 $ \a4' -> 
  let {a5' = fromEnumC a5} in 
  withDayCounter a6 $ \a6' -> 
  withYoYInflationIndex a7 $ \a7' -> 
  let {a8' = fromEnumC a8} in 
  withYieldTermStructure a9 $ \a9' -> 
  let {a10' = (fromIntegral . fromEnum) a10} in 
  withMaybeDay a11 $ \a11' -> 
  preErrorCheck $ \a12' -> 
  yearOnYearInflationSwapHelperRaw'_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
  peekYearOnYearInflationSwapHelper res >>= \res' ->
  errorCheck  a12'>>
  return (res')

{-# LINE 161 "./QuantLib/TermStructure/Inflation.chs" #-}


-- |Bootstrap helper for a 'QuantLib.Instrument.Bond.CPIBond' -- a 'CPIBondHelper', which is a
-- plain 'BondHelper' subclass with no extra methods, so it's returned as the generic
-- 'BondHelper' type (same shape as 'QuantLib.TermStructure.Yield.fixedRateBondHelper').
cpiBondHelper :: (GenQuote q) -> (Word) -- ^settlementDays
 -> (Double) -- ^faceAmount
 -> (Double) -- ^baseCPI
 -> ((Word,TimeUnit)) -- ^observationLag
 -> (GenZeroInflationIndex zidx) -> (CPIInterpolationType) -- ^observationInterpolation
 -> (Schedule) -> (NonEmpty Double) -- ^coupons
 -> (DayCounter) -- ^accrualDayCounter
 -> (BusinessDayConvention) -- ^paymentConvention
 -> (Maybe Day) -- ^issueDate
 -> (Calendar) -- ^paymentCalendar
 -> IO ((BondHelper))
cpiBondHelper :: forall q zidx.
GenQuote q
-> Word
-> Double
-> Double
-> (Word, TimeUnit)
-> GenZeroInflationIndex zidx
-> CPIInterpolationType
-> Schedule
-> NonEmpty Double
-> DayCounter
-> BusinessDayConvention
-> Maybe Day
-> Calendar
-> IO BondHelper
cpiBondHelper GenQuote q
a1 Word
a2 Double
a3 Double
a4 (Word, TimeUnit)
a5 GenZeroInflationIndex zidx
a6 CPIInterpolationType
a7 Schedule
a8 NonEmpty Double
a9 DayCounter
a10 BusinessDayConvention
a11 Maybe Day
a12 Calendar
a13 =
  GenQuote q -> (Ptr CQuote' -> IO BondHelper) -> IO BondHelper
forall q b. GenQuote q -> (Ptr CQuote' -> IO b) -> IO b
withQuote GenQuote q
a1 ((Ptr CQuote' -> IO BondHelper) -> IO BondHelper)
-> (Ptr CQuote' -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CQuote'
a1' -> 
  let {a2' :: CUInt
a2' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a2} in 
  let {a3' :: CDouble
a3' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a3} in 
  let {a4' :: CDouble
a4' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a4} in 
  let {(CInt
a5'1, CInt
a5'2) = (Word, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Word, TimeUnit)
a5} in 
  GenZeroInflationIndex zidx
-> (Ptr CZeroInflationIndex' -> IO BondHelper) -> IO BondHelper
forall zidx b.
GenZeroInflationIndex zidx
-> (Ptr CZeroInflationIndex' -> IO b) -> IO b
withZeroInflationIndex GenZeroInflationIndex zidx
a6 ((Ptr CZeroInflationIndex' -> IO BondHelper) -> IO BondHelper)
-> (Ptr CZeroInflationIndex' -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CZeroInflationIndex'
a6' -> 
  let {a7' :: CInt
a7' = CPIInterpolationType -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC CPIInterpolationType
a7} in 
  Schedule -> (Ptr CSchedule -> IO BondHelper) -> IO BondHelper
forall b. Schedule -> (Ptr CSchedule -> IO b) -> IO b
withSchedule Schedule
a8 ((Ptr CSchedule -> IO BondHelper) -> IO BondHelper)
-> (Ptr CSchedule -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CSchedule
a8' -> 
  NonEmpty Double
-> ((CUInt, Ptr CDouble) -> IO BondHelper) -> IO BondHelper
forall b. NonEmpty Double -> ((CUInt, Ptr CDouble) -> IO b) -> IO b
withNonEmptyDoubleArray NonEmpty Double
a9 (((CUInt, Ptr CDouble) -> IO BondHelper) -> IO BondHelper)
-> ((CUInt, Ptr CDouble) -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \(CUInt
a9'1, Ptr CDouble
a9'2) -> 
  DayCounter -> (Ptr CDayCounter -> IO BondHelper) -> IO BondHelper
forall b. DayCounter -> (Ptr CDayCounter -> IO b) -> IO b
withDayCounter DayCounter
a10 ((Ptr CDayCounter -> IO BondHelper) -> IO BondHelper)
-> (Ptr CDayCounter -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CDayCounter
a10' -> 
  let {a11' :: CInt
a11' = BusinessDayConvention -> CInt
forall a b. (Enum a, Integral b) => a -> b
fromEnumC BusinessDayConvention
a11} in 
  Maybe Day -> (CInt -> IO BondHelper) -> IO BondHelper
forall a. Maybe Day -> (CInt -> IO a) -> IO a
withMaybeDay Maybe Day
a12 ((CInt -> IO BondHelper) -> IO BondHelper)
-> (CInt -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \CInt
a12' -> 
  Calendar -> (Ptr CCalendar -> IO BondHelper) -> IO BondHelper
forall b. Calendar -> (Ptr CCalendar -> IO b) -> IO b
withCalendar Calendar
a13 ((Ptr CCalendar -> IO BondHelper) -> IO BondHelper)
-> (Ptr CCalendar -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \Ptr CCalendar
a13' -> 
  (Ptr (Ptr ()) -> IO BondHelper) -> IO BondHelper
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO BondHelper) -> IO BondHelper)
-> (Ptr (Ptr ()) -> IO BondHelper) -> IO BondHelper
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a14' -> 
  Ptr CQuote'
-> CUInt
-> CDouble
-> CDouble
-> CInt
-> CInt
-> Ptr CZeroInflationIndex'
-> CInt
-> Ptr CSchedule
-> CUInt
-> Ptr CDouble
-> Ptr CDayCounter
-> CInt
-> CInt
-> Ptr CCalendar
-> Ptr (Ptr ())
-> IO (Ptr CBondHelper')
cpiBondHelper'_ Ptr CQuote'
a1' CUInt
a2' CDouble
a3' CDouble
a4' CInt
a5'1  CInt
a5'2 Ptr CZeroInflationIndex'
a6' CInt
a7' Ptr CSchedule
a8' CUInt
a9'1  Ptr CDouble
a9'2 Ptr CDayCounter
a10' CInt
a11' CInt
a12' Ptr CCalendar
a13' Ptr (Ptr ())
a14' IO (Ptr CBondHelper')
-> (Ptr CBondHelper' -> IO BondHelper) -> IO BondHelper
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr CBondHelper'
res ->
  peekBondHelper res >>= \res' ->
  errorCheck  a14'>>
  return (res')

{-# LINE 177 "./QuantLib/TermStructure/Inflation.chs" #-}


-- |Bootstraps a zero-inflation term structure piecewise from a set of helpers, interpolating
-- between the bootstrapped nodes with the given 'Interpolation'.
piecewiseZeroInflationCurve :: Day -- ^referenceDate
  -> Day -- ^baseDate
  -> Frequency -> DayCounter -> NonEmpty ZeroCouponInflationSwapHelper -> Maybe Seasonality -> Interpolation
  -> IO PiecewiseZeroInflationCurve
piecewiseZeroInflationCurve r b f dc h s i = seasonalityArgs r s $ \sk sd sf sfs ->
  uncurryNested (qlPiecewiseZeroInflationCurve r b f dc (toList h) sk sd sf sfs) (qlInterpolation i)

qlPiecewiseZeroInflationCurve :: (Day) -> (Day) -> (Frequency) -> (DayCounter) -> ([ZeroCouponInflationSwapHelper]) -> (Int) -> (Day) -> (Frequency) -> ([Double]) -> (Int) -> (Int) -> (Int) -> IO ((PiecewiseZeroInflationCurve))
qlPiecewiseZeroInflationCurve a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
  withDay a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  let {a3' = (fromIntegral . fromEnum) a3} in 
  withDayCounter a4 $ \a4' -> 
  withZeroCouponInflationSwapHelperArray a5 $ \(a5'1, a5'2) -> 
  let {a6' = fromIntegral a6} in 
  withDay a7 $ \a7' -> 
  let {a8' = (fromIntegral . fromEnum) a8} in 
  withDoubleArray a9 $ \(a9'1, a9'2) -> 
  let {a10' = fromIntegral a10} in 
  let {a11' = fromIntegral a11} in 
  let {a12' = fromIntegral a12} in 
  preErrorCheck $ \a13' -> 
  qlPiecewiseZeroInflationCurve'_ a1' a2' a3' a4' a5'1  a5'2 a6' a7' a8' a9'1  a9'2 a10' a11' a12' a13' >>= \res ->
  peekPiecewiseZeroInflationCurve res >>= \res' ->
  errorCheck  a13'>>
  return (res')

{-# LINE 191 "./QuantLib/TermStructure/Inflation.chs" #-}


-- |Bootstraps a year-on-year inflation term structure piecewise from a set of helpers,
-- interpolating between the bootstrapped nodes with the given 'Interpolation'.
piecewiseYoyInflationCurve :: Day -- ^referenceDate
  -> Day -- ^baseDate
  -> Double -- ^baseYoYRate
  -> Frequency -> DayCounter -> NonEmpty YearOnYearInflationSwapHelper -> Maybe Seasonality -> Interpolation
  -> IO PiecewiseYoYInflationCurve
piecewiseYoyInflationCurve r b y f dc h s i = seasonalityArgs r s $ \sk sd sf sfs ->
  uncurryNested (qlPiecewiseYoYInflationCurve r b y f dc (toList h) sk sd sf sfs) (qlInterpolation i)

qlPiecewiseYoYInflationCurve :: (Day) -> (Day) -> (Double) -> (Frequency) -> (DayCounter) -> ([YearOnYearInflationSwapHelper]) -> (Int) -> (Day) -> (Frequency) -> ([Double]) -> (Int) -> (Int) -> (Int) -> IO ((PiecewiseYoYInflationCurve))
qlPiecewiseYoYInflationCurve a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 =
  withDay a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  let {a3' = realToFrac a3} in 
  let {a4' = (fromIntegral . fromEnum) a4} in 
  withDayCounter a5 $ \a5' -> 
  withYearOnYearInflationSwapHelperArray a6 $ \(a6'1, a6'2) -> 
  let {a7' = fromIntegral a7} in 
  withDay a8 $ \a8' -> 
  let {a9' = (fromIntegral . fromEnum) a9} in 
  withDoubleArray a10 $ \(a10'1, a10'2) -> 
  let {a11' = fromIntegral a11} in 
  let {a12' = fromIntegral a12} in 
  let {a13' = fromIntegral a13} in 
  preErrorCheck $ \a14' -> 
  qlPiecewiseYoYInflationCurve'_ a1' a2' a3' a4' a5' a6'1  a6'2 a7' a8' a9' a10'1  a10'2 a11' a12' a13' a14' >>= \res ->
  peekPiecewiseYoYInflationCurve res >>= \res' ->
  errorCheck  a14'>>
  return (res')

{-# LINE 206 "./QuantLib/TermStructure/Inflation.chs" #-}


-- |A YoY-inflation curve interpolating directly between given (date, rate) nodes, unlike
-- 'piecewiseYoyInflationCurve' bootstrap from swap helpers -- useful when the rates are
-- already known market YoY levels rather than swap quotes to calibrate against. The first
-- node is the curve's own base date\/rate.
interpolatedYoyInflationCurve :: Day -- ^referenceDate
  -> NonEmpty (Day, Double) -- ^dates, rates
  -> Frequency -> DayCounter -> Maybe Seasonality -> Interpolation
  -> IO YoYInflationTermStructure
interpolatedYoyInflationCurve r dr f dc s i = seasonalityArgs r s $ \sk sd sf sfs ->
  uncurryNested (qlInterpolatedYoYInflationCurve r ds rs f dc sk sd sf sfs) (qlInterpolation i)
  where (ds, rs) = unzip (toList dr)
qlInterpolatedYoYInflationCurve :: (Day) -> ([Day]) -> ([Double]) -> (Frequency) -> (DayCounter) -> (Int) -> (Day) -> (Frequency) -> ([Double]) -> (Int) -> (Int) -> (Int) -> IO ((YoYInflationTermStructure))
qlInterpolatedYoYInflationCurve a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
  withDay a1 $ \a1' -> 
  withDayArray a2 $ \(a2'1, a2'2) -> 
  withDoubleArrayRaw a3 $ \a3' -> 
  let {a4' = (fromIntegral . fromEnum) a4} in 
  withDayCounter a5 $ \a5' -> 
  let {a6' = fromIntegral a6} in 
  withDay a7 $ \a7' -> 
  let {a8' = (fromIntegral . fromEnum) a8} in 
  withDoubleArray a9 $ \(a9'1, a9'2) -> 
  let {a10' = fromIntegral a10} in 
  let {a11' = fromIntegral a11} in 
  let {a12' = fromIntegral a12} in 
  preErrorCheck $ \a13' -> 
  qlInterpolatedYoYInflationCurve'_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8' a9'1  a9'2 a10' a11' a12' a13' >>= \res ->
  peekYoYInflationTermStructure res >>= \res' ->
  errorCheck  a13'>>
  return (res')

{-# LINE 222 "./QuantLib/TermStructure/Inflation.chs" #-}


-- |A zero-coupon inflation curve interpolating directly between given (date, rate) nodes. The
-- first node is the curve's base date.
interpolatedZeroInflationCurve :: Day -- ^referenceDate
  -> NonEmpty (Day, Double) -- ^dates, rates
  -> Frequency -> DayCounter -> Maybe Seasonality -> Interpolation
  -> IO ZeroInflationTermStructure
interpolatedZeroInflationCurve r dr f dc s i = seasonalityArgs r s $ \sk sd sf sfs ->
  uncurryNested (qlInterpolatedZeroInflationCurve r ds rs f dc sk sd sf sfs) (qlInterpolation i)
  where (ds, rs) = unzip (toList dr)
qlInterpolatedZeroInflationCurve :: (Day) -> ([Day]) -> ([Double]) -> (Frequency) -> (DayCounter) -> (Int) -> (Day) -> (Frequency) -> ([Double]) -> (Int) -> (Int) -> (Int) -> IO ((ZeroInflationTermStructure))
qlInterpolatedZeroInflationCurve a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
  withDay a1 $ \a1' -> 
  withDayArray a2 $ \(a2'1, a2'2) -> 
  withDoubleArrayRaw a3 $ \a3' -> 
  let {a4' = (fromIntegral . fromEnum) a4} in 
  withDayCounter a5 $ \a5' -> 
  let {a6' = fromIntegral a6} in 
  withDay a7 $ \a7' -> 
  let {a8' = (fromIntegral . fromEnum) a8} in 
  withDoubleArray a9 $ \(a9'1, a9'2) -> 
  let {a10' = fromIntegral a10} in 
  let {a11' = fromIntegral a11} in 
  let {a12' = fromIntegral a12} in 
  preErrorCheck $ \a13' -> 
  qlInterpolatedZeroInflationCurve'_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8' a9'1  a9'2 a10' a11' a12' a13' >>= \res ->
  peekZeroInflationTermStructure res >>= \res' ->
  errorCheck  a13'>>
  return (res')

{-# LINE 236 "./QuantLib/TermStructure/Inflation.chs" #-}


-- |Multiplicative price seasonality applied by an inflation curve's zero and year-on-year rates.
-- Factors repeat every whole multiple of a year and are normalized to the curve's base date;
-- multi-year factors inconsistent at whole years around that date make construction throw.
data Seasonality
  = MultiplicativePriceSeasonality !Day !Frequency ![Double] -- ^seasonalityBaseDate, frequency, factors
  | KerkhofSeasonality !Day ![Double] -- ^seasonalityBaseDate, monthly factors

-- Flattens an optional seasonality into the shims' kind, base date, frequency and factors.
seasonalityArgs :: Day -> Maybe Seasonality -> (Int -> Day -> Frequency -> [Double] -> r) -> r
seasonalityArgs d s k = case s of
  Nothing -> k (-1) d NoFrequency []
  Just (MultiplicativePriceSeasonality b f fs) -> k 0 b f fs
  Just (KerkhofSeasonality b fs) -> k 1 b Monthly fs

-- |Zero-coupon inflation rate implied by the curve.
zeroRate :: (GenZeroInflationTermStructure z) -> (Day) -> (Bool) -- ^extrapolate
 -> IO ((Double))
zeroRate :: forall z.
GenZeroInflationTermStructure z -> Day -> Bool -> IO Double
zeroRate GenZeroInflationTermStructure z
a1 Day
a2 Bool
a3 =
  GenZeroInflationTermStructure z
-> (Ptr CZeroInflationTermStructure' -> IO Double) -> IO Double
forall z b.
GenZeroInflationTermStructure z
-> (Ptr CZeroInflationTermStructure' -> IO b) -> IO b
withZeroInflationTermStructure GenZeroInflationTermStructure z
a1 ((Ptr CZeroInflationTermStructure' -> IO Double) -> IO Double)
-> (Ptr CZeroInflationTermStructure' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CZeroInflationTermStructure'
a1' -> 
  Day -> (CInt -> IO Double) -> IO Double
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a2 ((CInt -> IO Double) -> IO Double)
-> (CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \CInt
a2' -> 
  let {a3' :: CInt
a3' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a3} in 
  (Ptr (Ptr ()) -> IO Double) -> IO Double
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO Double) -> IO Double)
-> (Ptr (Ptr ()) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a4' -> 
  Ptr CZeroInflationTermStructure'
-> CInt -> CInt -> Ptr (Ptr ()) -> IO CDouble
zeroRate'_ Ptr CZeroInflationTermStructure'
a1' CInt
a2' CInt
a3' Ptr (Ptr ())
a4' IO CDouble -> (CDouble -> IO Double) -> IO Double
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CDouble
res ->
  let {res' :: Double
res' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
res} in
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  a4'IO () -> IO Double -> IO Double
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Double -> IO Double
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

{-# LINE 254 "./QuantLib/TermStructure/Inflation.chs" #-}


-- |Inflation swap helpers paired with the only curve family each can reprice on.
class HasImpliedQuoteOn helper curve where
  -- |The swap rate that would make the helper reprice exactly on the given curve, bootstrapped
  -- from it or not.
  impliedQuoteOn :: helper -> curve -> IO Double
instance HasImpliedQuoteOn ZeroCouponInflationSwapHelper (GenZeroInflationTermStructure z) where
  impliedQuoteOn = qlZeroCouponInflationSwapHelperImpliedQuoteOn
instance HasImpliedQuoteOn YearOnYearInflationSwapHelper (GenYoYInflationTermStructure yoy) where
  impliedQuoteOn = qlYearOnYearInflationSwapHelperImpliedQuoteOn

qlZeroCouponInflationSwapHelperImpliedQuoteOn :: (ZeroCouponInflationSwapHelper) -> (GenZeroInflationTermStructure z) -> IO ((Double))
qlZeroCouponInflationSwapHelperImpliedQuoteOn :: forall z.
ZeroCouponInflationSwapHelper
-> GenZeroInflationTermStructure z -> IO Double
qlZeroCouponInflationSwapHelperImpliedQuoteOn ZeroCouponInflationSwapHelper
a1 GenZeroInflationTermStructure z
a2 =
  ZeroCouponInflationSwapHelper
-> (Ptr CZeroCouponInflationSwapHelper -> IO Double) -> IO Double
forall b.
ZeroCouponInflationSwapHelper
-> (Ptr CZeroCouponInflationSwapHelper -> IO b) -> IO b
withZeroCouponInflationSwapHelper ZeroCouponInflationSwapHelper
a1 ((Ptr CZeroCouponInflationSwapHelper -> IO Double) -> IO Double)
-> (Ptr CZeroCouponInflationSwapHelper -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CZeroCouponInflationSwapHelper
a1' -> 
  GenZeroInflationTermStructure z
-> (Ptr CZeroInflationTermStructure' -> IO Double) -> IO Double
forall z b.
GenZeroInflationTermStructure z
-> (Ptr CZeroInflationTermStructure' -> IO b) -> IO b
withZeroInflationTermStructure GenZeroInflationTermStructure z
a2 ((Ptr CZeroInflationTermStructure' -> IO Double) -> IO Double)
-> (Ptr CZeroInflationTermStructure' -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CZeroInflationTermStructure'
a2' -> 
  (Ptr (Ptr ()) -> IO Double) -> IO Double
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr ()) -> IO Double) -> IO Double)
-> (Ptr (Ptr ()) -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a3' -> 
  Ptr CZeroCouponInflationSwapHelper
-> Ptr CZeroInflationTermStructure' -> Ptr (Ptr ()) -> IO CDouble
qlZeroCouponInflationSwapHelperImpliedQuoteOn'_ Ptr CZeroCouponInflationSwapHelper
a1' Ptr CZeroInflationTermStructure'
a2' Ptr (Ptr ())
a3' IO CDouble -> (CDouble -> IO Double) -> IO Double
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CDouble
res ->
  let {res' :: Double
res' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
res} in
  Ptr (Ptr ()) -> IO ()
forall a. Ptr (Ptr a) -> IO ()
errorCheck  Ptr (Ptr ())
a3'IO () -> IO Double -> IO Double
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Double -> IO Double
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
res')

{-# LINE 267 "./QuantLib/TermStructure/Inflation.chs" #-}


qlYearOnYearInflationSwapHelperImpliedQuoteOn :: (YearOnYearInflationSwapHelper) -> (GenYoYInflationTermStructure yoy) -> IO ((Double))
qlYearOnYearInflationSwapHelperImpliedQuoteOn a1 a2 =
  withYearOnYearInflationSwapHelper a1 $ \a1' -> 
  withYoYInflationTermStructure a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  qlYearOnYearInflationSwapHelperImpliedQuoteOn'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 270 "./QuantLib/TermStructure/Inflation.chs" #-}


-- |Year-on-year inflation rate implied by the curve.
yoyRate :: (GenYoYInflationTermStructure yoy) -> (Day) -> (Bool) -- ^extrapolate
 -> IO ((Double))
yoyRate a1 a2 a3 =
  withYoYInflationTermStructure a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  let {a3' = C2HSImp.fromBool a3} in 
  preErrorCheck $ \a4' -> 
  yoyRate'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 274 "./QuantLib/TermStructure/Inflation.chs" #-}


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

foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlZeroCouponInflationSwapHelper"
  zeroCouponInflationSwapHelperRaw'_ :: ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CZeroCouponInflationSwapHelper)))))))))))))))

foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlZeroCouponInflationSwapHelper2"
  zeroCouponInflationSwapHelperBetweenDatesRaw'_ :: ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CZeroCouponInflationSwapHelper))))))))))))))))

foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlYearOnYearInflationSwapHelper2"
  yearOnYearInflationSwapHelperBetweenDatesRaw'_ :: ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYoYInflationIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CYearOnYearInflationSwapHelper)))))))))))))))))

foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlYearOnYearInflationSwapHelper"
  yearOnYearInflationSwapHelperRaw'_ :: ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYoYInflationIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CYieldTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CYearOnYearInflationSwapHelper))))))))))))))))

foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlCPIBondHelper"
  cpiBondHelper'_ :: ((C2HSImp.Ptr (CQuote')) -> (C2HSImp.CUInt -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CZeroInflationIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CSchedule)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CBondHelper')))))))))))))))))))

foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlPiecewiseZeroInflationCurve"
  qlPiecewiseZeroInflationCurve'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CZeroCouponInflationSwapHelper))) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CPiecewiseZeroInflationCurve'))))))))))))))))))

foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlPiecewiseYoYInflationCurve"
  qlPiecewiseYoYInflationCurve'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CYearOnYearInflationSwapHelper))) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CPiecewiseYoYInflationCurve')))))))))))))))))))

foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlInterpolatedYoYInflationCurve"
  qlInterpolatedYoYInflationCurve'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CYoYInflationTermStructure'))))))))))))))))))

foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlInterpolatedZeroInflationCurve"
  qlInterpolatedZeroInflationCurve'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CZeroInflationTermStructure'))))))))))))))))))

foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlZeroInflationTermStructureZeroRate"
  zeroRate'_ :: ((C2HSImp.Ptr (CZeroInflationTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlZeroCouponInflationSwapHelperImpliedQuoteOn"
  qlZeroCouponInflationSwapHelperImpliedQuoteOn'_ :: ((C2HSImp.Ptr (CZeroCouponInflationSwapHelper)) -> ((C2HSImp.Ptr (CZeroInflationTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlYearOnYearInflationSwapHelperImpliedQuoteOn"
  qlYearOnYearInflationSwapHelperImpliedQuoteOn'_ :: ((C2HSImp.Ptr (CYearOnYearInflationSwapHelper)) -> ((C2HSImp.Ptr (CYoYInflationTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/TermStructure/Inflation.chs.h qlYoYInflationTermStructureYoYRate"
  yoyRate'_ :: ((C2HSImp.Ptr (CYoYInflationTermStructure')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))