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


{-# LINE 1 "./QuantLib/Index/InterestRate.chs" #-}
{-# LANGUAGE TemplateHaskell, StandaloneDeriving, PatternSynonyms #-}
-- suppress warnings about unused Extra_ constructors
{-# OPTIONS_GHC -Wno-unused-top-binds #-}
module QuantLib.Index.InterestRate
  (
    -- * Types
    -- ** Interest-rate index hierarchy
    GenInterestRateIndex
  , InterestRateIndex
  , GenIborIndex
  , IborIndex
  , GenSwapIndex
  , SwapIndex
  , BMAIndex
  , OvernightIborIndex
  , SwapSpreadIndex
  , OvernightIndexedSwapIndex

    -- * Constructors
    -- ** BMA indices
  , bmaIndex

    -- ** Hierarchy conversion
  , asInterestRateIndex
  , asIborIndex
  , asSwapIndex

    -- ** Overnight and swap indices
  , OvernightIborIndexType(..)
  , overnightIborIndex

  , LiborSwapIndexType(..)
  , liborSwapIndex

  , overnightIndexedSwapIndex
  , swapIndex
  , swapIndexWithDiscountCurve
  , swapSpreadIndex

    -- ** Ibor index catalogue

  -- The bundled names are the fixed-tenor shortcut pattern synonyms defined below;
  -- @Euribor3M@ and @Euribor (3, Months)@ are the same value, usable interchangeably
  -- in expressions and in patterns.
  , IborConstructor(.., Bbsw1M, Bbsw2M, Bbsw3M, Bbsw4M, Bbsw5M, Bbsw6M
                      , BiborSW, Bibor1M, Bibor2M, Bibor3M, Bibor6M, Bibor9M, Bibor1Y
                      , Bkbm1M, Bkbm2M, Bkbm3M, Bkbm4M, Bkbm5M, Bkbm6M
                      , EuriborSW, Euribor2W, Euribor3W
                      , Euribor1M, Euribor2M, Euribor3M, Euribor4M, Euribor5M, Euribor6M
                      , Euribor7M, Euribor8M, Euribor9M, Euribor10M, Euribor11M, Euribor1Y
                      , Euribor365_SW, Euribor365_2W, Euribor365_3W
                      , Euribor365_1M, Euribor365_2M, Euribor365_3M, Euribor365_4M
                      , Euribor365_5M, Euribor365_6M, Euribor365_7M, Euribor365_8M
                      , Euribor365_9M, Euribor365_10M, Euribor365_11M, Euribor365_1Y
                      , EurLiborSW, EurLibor2W
                      , EurLibor1M, EurLibor2M, EurLibor3M, EurLibor4M, EurLibor5M, EurLibor6M
                      , EurLibor7M, EurLibor8M, EurLibor9M, EurLibor10M, EurLibor11M, EurLibor1Y)
  , iborIndex
  , overnightIndex

    -- * Inspectors
    -- ** Index dates and conventions
  , fixingSchedule
  , forecastFixing
  , currency
  , dayCounter
  , fixingDays
  , tenor
  , fixingDate
  , valueDate
  , maturityDate
  , businessDayConvention
  , endOfMonth

    -- ** Underlying swaps and history
  , underlyingSwap
  , underlyingOis

  , historicalRatesAnalysis
  ) where
import qualified Foreign.C.String as C2HSImp
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 qualified System.IO.Unsafe as C2HSImp


import QuantLib.Internal
import QuantLib.Internal.Syntax
import QuantLib.Internal.Common
import QuantLib.Internal.Type
import QuantLib.Index (historicalIndexAnalysis)
-- Plain (non-c2hs) import: QuantLib.CashFlow is later in exposed-modules than
-- this file, so a {#import#} here would need its .chi before it exists.
-- overnightIndexedSwapIndex below marshals RateAveragingType as a plain Int
-- via fromEnum instead.
import QuantLib.CashFlow (RateAveragingType)
-- Only for IborConstructor's Read instance below (deriveReadInstance's materializer
-- table): this module already defines its own `currency`/`dayCounter` (an
-- InterestRateIndex's currency/day counter, unrelated), so these come in qualified to
-- avoid clashing with them.
import QuantLib.Time.Calendar (calendar)
import qualified QuantLib.Currency as Ccy (currency)
import qualified QuantLib.Time.Schedule as Sched (dayCounter)
import Data.List.NonEmpty(NonEmpty, toList)








{-# LINE 106 "./QuantLib/Index/InterestRate.chs" #-}


{-# LINE 107 "./QuantLib/Index/InterestRate.chs" #-}


{-# LINE 108 "./QuantLib/Index/InterestRate.chs" #-}


{-# LINE 109 "./QuantLib/Index/InterestRate.chs" #-}


{-# LINE 110 "./QuantLib/Index/InterestRate.chs" #-}


{-# LINE 111 "./QuantLib/Index/InterestRate.chs" #-}


{-# LINE 112 "./QuantLib/Index/InterestRate.chs" #-}


{-# LINE 113 "./QuantLib/Index/InterestRate.chs" #-}


{-# LINE 114 "./QuantLib/Index/InterestRate.chs" #-}


{-# LINE 115 "./QuantLib/Index/InterestRate.chs" #-}


{-# LINE 116 "./QuantLib/Index/InterestRate.chs" #-}


{-# LINE 117 "./QuantLib/Index/InterestRate.chs" #-}


{-# LINE 118 "./QuantLib/Index/InterestRate.chs" #-}


{-# LINE 119 "./QuantLib/Index/InterestRate.chs" #-}


data OvernightIborIndexType = Aonia
                            | Eonia
                            | Estr
                            | FedFunds
                            | Nzocr
                            | Sofr
                            | Sonia
                            | Cdi
                            | Corra
                            | Kofr
                            | Destr
                            | Swestr
                            | Shir
                            | Tonar
                            | Saron
                            | Zaronia
  deriving (Show,Eq,Read)
instance Enum OvernightIborIndexType where
  succ Aonia = Eonia
  succ Eonia = Estr
  succ Estr = FedFunds
  succ FedFunds = Nzocr
  succ Nzocr = Sofr
  succ Sofr = Sonia
  succ Sonia = Cdi
  succ Cdi = Corra
  succ Corra = Kofr
  succ Kofr = Destr
  pred :: LiborSwapIndexType -> LiborSwapIndexType
succ Destr = Swestr
  succ Swestr = Shir
  succ Shir = Tonar
  succ Tonar = Saron
  succ Saron = Zaronia
  succ Zaronia = error "OvernightIborIndexType.succ: Zaronia has no successor"

  pred Eonia = Aonia
  pred Estr = Eonia
  pred FedFunds = Estr
  pred Nzocr = FedFunds
  pred Sofr = Nzocr
  pred Sonia = Sofr
  pred Cdi = Sonia
  pred Corra = Cdi
  pred Kofr = Corra
  pred Destr = Kofr
  pred Swestr = Destr
  pred Shir = Swestr
  pred Tonar = Shir
  pred Saron = Tonar
  pred Zaronia = Saron
  pred Aonia = error "OvernightIborIndexType.pred: Aonia has no predecessor"

  enumFromTo from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from Zaronia

  fromEnum Aonia = 0
  fromEnum Eonia = 1
  fromEnum Estr = 2
  fromEnum FedFunds = 3
  fromEnum Nzocr = 4
  fromEnum Sofr = 5
  fromEnum Sonia = 6
  fromEnum Cdi = 7
  fromEnum Corra = 8
  fromEnum Kofr = 9
  fromEnum Destr = 10
  fromEnum Swestr = 11
  fromEnum Shir = 12
  fromEnum Tonar = 13
  fromEnum Saron = 14
  fromEnum Zaronia = 15

  toEnum 0 = Aonia
  toEnum 1 = Eonia
  toEnum 2 = Estr
  toEnum 3 = FedFunds
  toEnum 4 = Nzocr
  toEnum 5 = Sofr
  toEnum 6 = Sonia
  toEnum 7 = Cdi
  toEnum 8 = Corra
  toEnum 9 = Kofr
  toEnum 10 = Destr
  toEnum 11 = Swestr
  toEnum 12 = Shir
  toEnum 13 = Tonar
  toEnum 14 = Saron
  toEnum 15 = Zaronia
  toEnum unmatched = error ("OvernightIborIndexType.toEnum: Cannot match " ++ show unmatched)

{-# LINE 121 "./QuantLib/Index/InterestRate.chs" #-}

data LiborSwapIndexType = ChfLiborSwapIsdaFix
                        | EurLiborSwapIfrFix
                        | EurLiborSwapIsdaFixA
                        | EurLiborSwapIsdaFixB
                        | EuriborSwapIfrFix
                        | EuriborSwapIsdaFixA
                        | EuriborSwapIsdaFixB
                        | GbpLiborSwapIsdaFix
                        | JpyLiborSwapIsdaFixAm
                        | JpyLiborSwapIsdaFixPm
                        | UsdLiborSwapIsdaFixAm
                        | UsdLiborSwapIsdaFixPm
  deriving (Show,Eq,Read)
instance Enum LiborSwapIndexType where
  succ ChfLiborSwapIsdaFix = EurLiborSwapIfrFix
  succ EurLiborSwapIfrFix = EurLiborSwapIsdaFixA
  succ EurLiborSwapIsdaFixA = EurLiborSwapIsdaFixB
  succ EurLiborSwapIsdaFixB = EuriborSwapIfrFix
  succ EuriborSwapIfrFix = EuriborSwapIsdaFixA
  succ EuriborSwapIsdaFixA = EuriborSwapIsdaFixB
  succ EuriborSwapIsdaFixB = GbpLiborSwapIsdaFix
  succ GbpLiborSwapIsdaFix = JpyLiborSwapIsdaFixAm
  succ JpyLiborSwapIsdaFixAm = JpyLiborSwapIsdaFixPm
  succ JpyLiborSwapIsdaFixPm = UsdLiborSwapIsdaFixAm
  succ UsdLiborSwapIsdaFixAm = UsdLiborSwapIsdaFixPm
  succ UsdLiborSwapIsdaFixPm = error "LiborSwapIndexType.succ: UsdLiborSwapIsdaFixPm has no successor"

  pred EurLiborSwapIfrFix = ChfLiborSwapIsdaFix
  pred EurLiborSwapIsdaFixA = EurLiborSwapIfrFix
  pred EurLiborSwapIsdaFixB = EurLiborSwapIsdaFixA
  pred EuriborSwapIfrFix = EurLiborSwapIsdaFixB
  pred EuriborSwapIsdaFixA = EuriborSwapIfrFix
  pred EuriborSwapIsdaFixB = EuriborSwapIsdaFixA
  pred GbpLiborSwapIsdaFix = EuriborSwapIsdaFixB
  pred JpyLiborSwapIsdaFixAm = GbpLiborSwapIsdaFix
  pred JpyLiborSwapIsdaFixPm = JpyLiborSwapIsdaFixAm
  pred UsdLiborSwapIsdaFixAm = JpyLiborSwapIsdaFixPm
  pred UsdLiborSwapIsdaFixPm = UsdLiborSwapIsdaFixAm
  pred ChfLiborSwapIsdaFix = error "LiborSwapIndexType.pred: ChfLiborSwapIsdaFix has no predecessor"

  enumFromTo from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from UsdLiborSwapIsdaFixPm

  fromEnum ChfLiborSwapIsdaFix = 0
  fromEnum EurLiborSwapIfrFix = 1
  fromEnum EurLiborSwapIsdaFixA = 2
  fromEnum EurLiborSwapIsdaFixB = 3
  fromEnum EuriborSwapIfrFix = 4
  fromEnum EuriborSwapIsdaFixA = 5
  fromEnum EuriborSwapIsdaFixB = 6
  fromEnum GbpLiborSwapIsdaFix = 7
  fromEnum JpyLiborSwapIsdaFixAm = 8
  fromEnum JpyLiborSwapIsdaFixPm = 9
  fromEnum UsdLiborSwapIsdaFixAm = 10
  fromEnum UsdLiborSwapIsdaFixPm = 11

  toEnum 0 = ChfLiborSwapIsdaFix
  toEnum 1 = EurLiborSwapIfrFix
  toEnum 2 = EurLiborSwapIsdaFixA
  toEnum 3 = EurLiborSwapIsdaFixB
  toEnum 4 = EuriborSwapIfrFix
  toEnum 5 = EuriborSwapIsdaFixA
  toEnum 6 = EuriborSwapIsdaFixB
  toEnum 7 = GbpLiborSwapIsdaFix
  toEnum 8 = JpyLiborSwapIsdaFixAm
  toEnum 9 = JpyLiborSwapIsdaFixPm
  toEnum 10 = UsdLiborSwapIsdaFixAm
  toEnum 11 = UsdLiborSwapIsdaFixPm
  toEnum unmatched = error ("LiborSwapIndexType.toEnum: Cannot match " ++ show unmatched)

{-# LINE 122 "./QuantLib/Index/InterestRate.chs" #-}

data IborIndexType = Ibor__Bbsw
                   | Ibor__Bibor
                   | Ibor__Bkbm
                   | Ibor__Cdor
                   | Ibor__EurLibor
                   | Ibor__AudLibor
                   | Ibor__CadLibor
                   | Ibor__ChfLibor
                   | Ibor__DkkLibor
                   | Ibor__GbpLibor
                   | Ibor__JpyLibor
                   | Ibor__NzdLibor
                   | Ibor__SekLibor
                   | Ibor__UsdLibor
                   | Ibor__Euribor
                   | Ibor__Euribor365
                   | Ibor__Jibar
                   | Ibor__Mosprime
                   | Ibor__Pribor
                   | Ibor__Robor
                   | Ibor__Shibor
                   | Ibor__THBFIX
                   | Ibor__TRLibor
                   | Ibor__Tibor
                   | Ibor__Wibor
                   | Ibor__Zibor
                   | Ibor__Nibor
                   | Ibor__IborIndexTypeLast
  deriving (Show,Eq,Read)
instance Enum IborIndexType where
  succ Ibor__Bbsw = Ibor__Bibor
  succ Ibor__Bibor = Ibor__Bkbm
  succ Ibor__Bkbm = Ibor__Cdor
  succ Ibor__Cdor = Ibor__EurLibor
  succ Ibor__EurLibor = Ibor__AudLibor
  succ Ibor__AudLibor = Ibor__CadLibor
  succ Ibor__CadLibor = Ibor__ChfLibor
  succ Ibor__ChfLibor = Ibor__DkkLibor
  succ Ibor__DkkLibor = Ibor__GbpLibor
  succ Ibor__GbpLibor = Ibor__JpyLibor
  succ Ibor__JpyLibor = Ibor__NzdLibor
  succ Ibor__NzdLibor = Ibor__SekLibor
  succ Ibor__SekLibor = Ibor__UsdLibor
  succ Ibor__UsdLibor = Ibor__Euribor
  succ Ibor__Euribor = Ibor__Euribor365
  succ Ibor__Euribor365 = Ibor__Jibar
  succ Ibor__Jibar = Ibor__Mosprime
  succ Ibor__Mosprime = Ibor__Pribor
  succ Ibor__Pribor = Ibor__Robor
  succ Ibor__Robor = Ibor__Shibor
  succ Ibor__Shibor = Ibor__THBFIX
  succ Ibor__THBFIX = Ibor__TRLibor
  succ Ibor__TRLibor = Ibor__Tibor
  succ Ibor__Tibor = Ibor__Wibor
  succ Ibor__Wibor = Ibor__Zibor
  succ Ibor__Zibor = Ibor__Nibor
  succ Ibor__Nibor = Ibor__IborIndexTypeLast
  succ Ibor__IborIndexTypeLast = error "IborIndexType.succ: Ibor__IborIndexTypeLast has no successor"

  pred Ibor__Bibor = Ibor__Bbsw
  pred Ibor__Bkbm = Ibor__Bibor
  pred Ibor__Cdor = Ibor__Bkbm
  pred Ibor__EurLibor = Ibor__Cdor
  pred Ibor__AudLibor = Ibor__EurLibor
  pred Ibor__CadLibor = Ibor__AudLibor
  pred Ibor__ChfLibor = Ibor__CadLibor
  pred Ibor__DkkLibor = Ibor__ChfLibor
  pred Ibor__GbpLibor = Ibor__DkkLibor
  pred Ibor__JpyLibor = Ibor__GbpLibor
  pred Ibor__NzdLibor = Ibor__JpyLibor
  pred Ibor__SekLibor = Ibor__NzdLibor
  pred Ibor__UsdLibor = Ibor__SekLibor
  pred Ibor__Euribor = Ibor__UsdLibor
  pred Ibor__Euribor365 = Ibor__Euribor
  pred Ibor__Jibar = Ibor__Euribor365
  pred Ibor__Mosprime = Ibor__Jibar
  pred Ibor__Pribor = Ibor__Mosprime
  pred Ibor__Robor = Ibor__Pribor
  pred Ibor__Shibor = Ibor__Robor
  pred Ibor__THBFIX = Ibor__Shibor
  pred Ibor__TRLibor = Ibor__THBFIX
  pred Ibor__Tibor = Ibor__TRLibor
  pred Ibor__Wibor = Ibor__Tibor
  pred Ibor__Zibor = Ibor__Wibor
  pred Ibor__Nibor = Ibor__Zibor
  pred Ibor__IborIndexTypeLast = Ibor__Nibor
  pred Ibor__Bbsw = error "IborIndexType.pred: Ibor__Bbsw has no predecessor"

  enumFromTo from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from Ibor__IborIndexTypeLast

  fromEnum Ibor__Bbsw = 0
  fromEnum Ibor__Bibor = 1
  fromEnum Ibor__Bkbm = 2
  fromEnum Ibor__Cdor = 3
  fromEnum Ibor__EurLibor = 4
  fromEnum Ibor__AudLibor = 5
  fromEnum Ibor__CadLibor = 6
  fromEnum Ibor__ChfLibor = 7
  fromEnum Ibor__DkkLibor = 8
  fromEnum Ibor__GbpLibor = 9
  fromEnum Ibor__JpyLibor = 10
  fromEnum Ibor__NzdLibor = 11
  fromEnum Ibor__SekLibor = 12
  fromEnum Ibor__UsdLibor = 13
  fromEnum Ibor__Euribor = 14
  fromEnum Ibor__Euribor365 = 15
  fromEnum Ibor__Jibar = 16
  fromEnum Ibor__Mosprime = 17
  fromEnum Ibor__Pribor = 18
  fromEnum Ibor__Robor = 19
  fromEnum Ibor__Shibor = 20
  fromEnum Ibor__THBFIX = 21
  fromEnum Ibor__TRLibor = 22
  fromEnum Ibor__Tibor = 23
  fromEnum Ibor__Wibor = 24
  fromEnum Ibor__Zibor = 25
  fromEnum Ibor__Nibor = 26
  fromEnum Ibor__IborIndexTypeLast = 27

  toEnum 0 = Ibor__Bbsw
  toEnum 1 = Ibor__Bibor
  toEnum 2 = Ibor__Bkbm
  toEnum 3 = Ibor__Cdor
  toEnum 4 = Ibor__EurLibor
  toEnum 5 = Ibor__AudLibor
  toEnum 6 = Ibor__CadLibor
  toEnum 7 = Ibor__ChfLibor
  toEnum 8 = Ibor__DkkLibor
  toEnum 9 = Ibor__GbpLibor
  toEnum 10 = Ibor__JpyLibor
  toEnum 11 = Ibor__NzdLibor
  toEnum 12 = Ibor__SekLibor
  toEnum 13 = Ibor__UsdLibor
  toEnum 14 = Ibor__Euribor
  toEnum 15 = Ibor__Euribor365
  toEnum 16 = Ibor__Jibar
  toEnum 17 = Ibor__Mosprime
  toEnum 18 = Ibor__Pribor
  toEnum 19 = Ibor__Robor
  toEnum 20 = Ibor__Shibor
  toEnum 21 = Ibor__THBFIX
  toEnum 22 = Ibor__TRLibor
  toEnum 23 = Ibor__Tibor
  toEnum 24 = Ibor__Wibor
  toEnum 25 = Ibor__Zibor
  toEnum 26 = Ibor__Nibor
  toEnum 27 = Ibor__IborIndexTypeLast
  toEnum unmatched = error ("IborIndexType.toEnum: Cannot match " ++ show unmatched)

{-# LINE 123 "./QuantLib/Index/InterestRate.chs" #-}

data IborDailyTenorIndexType = Ibor__EurDailyTenorLibor
                             | Ibor__ChfDailyTenorLibor
                             | Ibor__GbpDailyTenorLibor
                             | Ibor__JpyDailyTenorLibor
                             | Ibor__UsdDailyTenorLibor
                             | Ibor__IborDailyTenorIndexTypeLast
  deriving (Show,Eq,Read)
instance Enum IborDailyTenorIndexType where
  succ Ibor__EurDailyTenorLibor = Ibor__ChfDailyTenorLibor
  succ Ibor__ChfDailyTenorLibor = Ibor__GbpDailyTenorLibor
  succ Ibor__GbpDailyTenorLibor = Ibor__JpyDailyTenorLibor
  succ Ibor__JpyDailyTenorLibor = Ibor__UsdDailyTenorLibor
  succ Ibor__UsdDailyTenorLibor = Ibor__IborDailyTenorIndexTypeLast
  succ Ibor__IborDailyTenorIndexTypeLast = error "IborDailyTenorIndexType.succ: Ibor__IborDailyTenorIndexTypeLast has no successor"

  pred Ibor__ChfDailyTenorLibor = Ibor__EurDailyTenorLibor
  pred Ibor__GbpDailyTenorLibor = Ibor__ChfDailyTenorLibor
  pred Ibor__JpyDailyTenorLibor = Ibor__GbpDailyTenorLibor
  pred Ibor__UsdDailyTenorLibor = Ibor__JpyDailyTenorLibor
  pred Ibor__IborDailyTenorIndexTypeLast = Ibor__UsdDailyTenorLibor
  pred Ibor__EurDailyTenorLibor = error "IborDailyTenorIndexType.pred: Ibor__EurDailyTenorLibor has no predecessor"

  enumFromTo from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from Ibor__IborDailyTenorIndexTypeLast

  fromEnum Ibor__EurDailyTenorLibor = 0
  fromEnum Ibor__ChfDailyTenorLibor = 1
  fromEnum Ibor__GbpDailyTenorLibor = 2
  fromEnum Ibor__JpyDailyTenorLibor = 3
  fromEnum Ibor__UsdDailyTenorLibor = 4
  fromEnum Ibor__IborDailyTenorIndexTypeLast = 5

  toEnum 0 = Ibor__EurDailyTenorLibor
  toEnum 1 = Ibor__ChfDailyTenorLibor
  toEnum 2 = Ibor__GbpDailyTenorLibor
  toEnum 3 = Ibor__JpyDailyTenorLibor
  toEnum 4 = Ibor__UsdDailyTenorLibor
  toEnum 5 = Ibor__IborDailyTenorIndexTypeLast
  toEnum unmatched = error ("IborDailyTenorIndexType.toEnum: Cannot match " ++ show unmatched)

{-# LINE 124 "./QuantLib/Index/InterestRate.chs" #-}

data IborONIndexType = Ibor__CadLiborON
                     | Ibor__EurLiborON
                     | Ibor__GbpLiborON
                     | Ibor__UsdLiborON
  deriving (Show,Eq,Read)
instance Enum IborONIndexType where
  succ Ibor__CadLiborON = Ibor__EurLiborON
  succ Ibor__EurLiborON = Ibor__GbpLiborON
  succ Ibor__GbpLiborON = Ibor__UsdLiborON
  succ Ibor__UsdLiborON = error "IborONIndexType.succ: Ibor__UsdLiborON has no successor"

  pred Ibor__EurLiborON = Ibor__CadLiborON
  pred Ibor__GbpLiborON = Ibor__EurLiborON
  pred Ibor__UsdLiborON = Ibor__GbpLiborON
  pred Ibor__CadLiborON = error "IborONIndexType.pred: Ibor__CadLiborON has no predecessor"

  enumFromTo from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from Ibor__UsdLiborON

  fromEnum Ibor__CadLiborON = 0
  fromEnum Ibor__EurLiborON = 1
  fromEnum Ibor__GbpLiborON = 2
  fromEnum Ibor__UsdLiborON = 3

  toEnum 0 = Ibor__CadLiborON
  toEnum 1 = Ibor__EurLiborON
  toEnum 2 = Ibor__GbpLiborON
  toEnum 3 = Ibor__UsdLiborON
  toEnum unmatched = error ("IborONIndexType.toEnum: Cannot match " ++ show unmatched)

{-# LINE 125 "./QuantLib/Index/InterestRate.chs" #-}


-- the fully generic, non-enum-ordinal IborConstructor cases, merged into IborConstructor by
-- deriveIborConstructor below alongside the plain-tenor/daily-tenor/overnight cases generated
-- straight from IborIndexType/IborDailyTenorIndexType/IborONIndexType
data IborExtra =
      Extra__Ibor String -- ^familyName
      (Word, TimeUnit) -- ^tenor
      Word -- ^settlementDays
      Currency
      Calendar -- ^fixingCalendar
      BusinessDayConvention
      Bool -- ^endOfMonth
      DayCounter
    | Extra__Libor String (Word, TimeUnit) Word -- ^settlementDays
      Currency Calendar DayCounter
    | Extra__DailyTenorLibor String Word -- ^settlementDays
      Currency Calendar DayCounter
    | Extra__CustomIbor String -- ^familyName
      (Word, TimeUnit) -- ^tenor
      Word -- ^settlementDays
      Currency
      Calendar -- ^fixingCalendar
      Calendar -- ^valueCalendar
      Calendar -- ^maturityCalendar
      BusinessDayConvention
      Bool -- ^endOfMonth
      DayCounter

$(deriveIborConstructor IborConstructorSpec
    { iborTypeName = "IborConstructor"
    , iborOrdinalFn = "iborIndexOrdinal"
    , iborTenorFn = "iborIndexTenor"
    , iborTenorEnum = ''IborIndexType
    , iborDailyTenorEnum = ''IborDailyTenorIndexType
    , iborOvernightEnum = ''IborONIndexType
    , iborExtraType = ''IborExtra
    })

deriving instance Show IborConstructor
deriving instance Eq IborConstructor

-- Spliced here rather than alongside IborConstructor's declaration just above: this needs
-- `calendar`/`Ccy.currency`/`Sched.dayCounter`, none of which InterestRate.chs's own
-- declaration site could import without a cycle back through this module. See
-- deriveReadInstance's comment in Internal/Syntax.hs for the general shape; Schedule.chs and
-- Calendar.chs use the identical pattern for DayCounterConstructor/CalendarConstructor.
$(deriveReadInstance ''IborConstructor
    [ ("Calendar", 'calendar)
    , ("Currency", 'Ccy.currency)
    , ("DayCounter", 'Sched.dayCounter)
    ])

-- Fixed-tenor shortcuts mirroring upstream's thin @Euribor3M@-style subclasses. Bidirectional
-- pattern synonyms keep family and tenor in the parameterized value instead of a second dispatch
-- table that could drift.
pattern Bbsw1M, Bbsw2M, Bbsw3M, Bbsw4M, Bbsw5M, Bbsw6M :: IborConstructor
pattern Bbsw1M = Bbsw (1, Months)
pattern Bbsw2M = Bbsw (2, Months)
pattern Bbsw3M = Bbsw (3, Months)
pattern Bbsw4M = Bbsw (4, Months)
pattern Bbsw5M = Bbsw (5, Months)
pattern Bbsw6M = Bbsw (6, Months)

pattern BiborSW, Bibor1M, Bibor2M, Bibor3M, Bibor6M, Bibor9M, Bibor1Y :: IborConstructor
pattern BiborSW = Bibor (1, Weeks)
pattern Bibor1M = Bibor (1, Months)
pattern Bibor2M = Bibor (2, Months)
pattern Bibor3M = Bibor (3, Months)
pattern Bibor6M = Bibor (6, Months)
pattern Bibor9M = Bibor (9, Months)
pattern Bibor1Y = Bibor (1, Years)

pattern Bkbm1M, Bkbm2M, Bkbm3M, Bkbm4M, Bkbm5M, Bkbm6M :: IborConstructor
pattern Bkbm1M = Bkbm (1, Months)
pattern Bkbm2M = Bkbm (2, Months)
pattern Bkbm3M = Bkbm (3, Months)
pattern Bkbm4M = Bkbm (4, Months)
pattern Bkbm5M = Bkbm (5, Months)
pattern Bkbm6M = Bkbm (6, Months)

pattern EuriborSW, Euribor2W, Euribor3W, Euribor1M, Euribor2M, Euribor3M, Euribor4M
  , Euribor5M, Euribor6M, Euribor7M, Euribor8M, Euribor9M, Euribor10M, Euribor11M
  , Euribor1Y :: IborConstructor
pattern EuriborSW = Euribor (1, Weeks)
pattern Euribor2W = Euribor (2, Weeks)
pattern Euribor3W = Euribor (3, Weeks)
pattern Euribor1M = Euribor (1, Months)
pattern Euribor2M = Euribor (2, Months)
pattern Euribor3M = Euribor (3, Months)
pattern Euribor4M = Euribor (4, Months)
pattern Euribor5M = Euribor (5, Months)
pattern Euribor6M = Euribor (6, Months)
pattern Euribor7M = Euribor (7, Months)
pattern Euribor8M = Euribor (8, Months)
pattern Euribor9M = Euribor (9, Months)
pattern Euribor10M = Euribor (10, Months)
pattern Euribor11M = Euribor (11, Months)
pattern Euribor1Y = Euribor (1, Years)

pattern Euribor365_SW, Euribor365_2W, Euribor365_3W, Euribor365_1M, Euribor365_2M
  , Euribor365_3M, Euribor365_4M, Euribor365_5M, Euribor365_6M, Euribor365_7M
  , Euribor365_8M, Euribor365_9M, Euribor365_10M, Euribor365_11M
  , Euribor365_1Y :: IborConstructor
pattern Euribor365_SW = Euribor365 (1, Weeks)
pattern Euribor365_2W = Euribor365 (2, Weeks)
pattern Euribor365_3W = Euribor365 (3, Weeks)
pattern Euribor365_1M = Euribor365 (1, Months)
pattern Euribor365_2M = Euribor365 (2, Months)
pattern Euribor365_3M = Euribor365 (3, Months)
pattern Euribor365_4M = Euribor365 (4, Months)
pattern Euribor365_5M = Euribor365 (5, Months)
pattern Euribor365_6M = Euribor365 (6, Months)
pattern Euribor365_7M = Euribor365 (7, Months)
pattern Euribor365_8M = Euribor365 (8, Months)
pattern Euribor365_9M = Euribor365 (9, Months)
pattern Euribor365_10M = Euribor365 (10, Months)
pattern Euribor365_11M = Euribor365 (11, Months)
pattern Euribor365_1Y = Euribor365 (1, Years)

pattern EurLiborSW, EurLibor2W, EurLibor1M, EurLibor2M, EurLibor3M, EurLibor4M
  , EurLibor5M, EurLibor6M, EurLibor7M, EurLibor8M, EurLibor9M, EurLibor10M
  , EurLibor11M, EurLibor1Y :: IborConstructor
pattern EurLiborSW = EurLibor (1, Weeks)
pattern EurLibor2W = EurLibor (2, Weeks)
pattern EurLibor1M = EurLibor (1, Months)
pattern EurLibor2M = EurLibor (2, Months)
pattern EurLibor3M = EurLibor (3, Months)
pattern EurLibor4M = EurLibor (4, Months)
pattern EurLibor5M = EurLibor (5, Months)
pattern EurLibor6M = EurLibor (6, Months)
pattern EurLibor7M = EurLibor (7, Months)
pattern EurLibor8M = EurLibor (8, Months)
pattern EurLibor9M = EurLibor (9, Months)
pattern EurLibor10M = EurLibor (10, Months)
pattern EurLibor11M = EurLibor (11, Months)
pattern EurLibor1Y = EurLibor (1, Years)

iborIndex :: IborConstructor -> Maybe (GenYieldTermStructure y) -> IO IborIndex
iborIndex (Ibor n p s cr ca bd b dc) ts = qlIborIndex n p s cr ca bd b dc ts
iborIndex (Libor n p s cr ca dc) ts = qlLibor n p s cr ca dc ts
iborIndex (DailyTenorLibor n c cr ca dc) ts = qlDailyTenorLibor n c cr ca dc ts
iborIndex (CustomIbor n p s cr fc vc mc bd b dc) ts = qlCustomIborIndex n p s cr fc vc mc bd b dc ts
iborIndex c ts = qlCreateIbor (iborIndexOrdinal c) (iborIndexTenor c) ts

-- |Creates the BMA (Bond Market Association) short-term tax-exempt index, optionally linked to a forwarding curve.
bmaIndex :: (Maybe (GenYieldTermStructure y)) -> IO ((BMAIndex))
bmaIndex a1 =
  withMaybeYieldTermStructure a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  bmaIndex'_ a1' a2' >>= \res ->
  peekBMAIndex res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 271 "./QuantLib/Index/InterestRate.chs" #-}


-- |This method returns a schedule of fixing dates between start and end.
fixingSchedule :: (BMAIndex) -> (Day) -> (Day) -> IO ((Schedule))
fixingSchedule a1 a2 a3 =
  withBMAIndex a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  withDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  fixingSchedule'_ a1' a2' a3' a4' >>= \res ->
  peekSchedule res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 274 "./QuantLib/Index/InterestRate.chs" #-}


-- |It can be overridden to implement particular conventions.
forecastFixing :: (GenInterestRateIndex ridx) -> (Day) -> IO ((Double))
forecastFixing a1 a2 =
  withInterestRateIndex a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  forecastFixing'_ a1' a2' a3' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 277 "./QuantLib/Index/InterestRate.chs" #-}


-- |Returns the index's underlying currency.
currency :: (GenInterestRateIndex ridx) -> IO ((Currency))
currency a1 =
  withInterestRateIndex a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  currency'_ a1' a2' >>= \res ->
  peekCurrency res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 280 "./QuantLib/Index/InterestRate.chs" #-}


-- |Returns the day counter used by the index.
dayCounter :: (GenInterestRateIndex ridx) -> IO ((DayCounter))
dayCounter a1 =
  withInterestRateIndex a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  dayCounter'_ a1' a2' >>= \res ->
  peekDayCounter res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 283 "./QuantLib/Index/InterestRate.chs" #-}


-- |Returns the number of business days between a fixing date and the corresponding value date.
fixingDays :: (GenInterestRateIndex ridx) -> (Word)
fixingDays a1 =
  C2HSImp.unsafePerformIO $
  withInterestRateIndex a1 $ \a1' -> 
  fixingDays'_ a1' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 286 "./QuantLib/Index/InterestRate.chs" #-}


-- |Returns the index's tenor.
tenor :: (GenInterestRateIndex ridx) -> IO ((Word), (TimeUnit))
tenor a1 =
  withInterestRateIndex a1 $ \a1' -> 
  preEnum $ \a2' -> 
  preErrorCheck $ \a3' -> 
  tenor'_ a1' a2' a3' >>= \res ->
  let {res' = fromIntegral res} in
  peekEnum  a2'>>= \a2'' -> 
  errorCheck  a3'>>
  return (res', a2'')

{-# LINE 289 "./QuantLib/Index/InterestRate.chs" #-}


-- |Returns the fixing date corresponding to a value date, using this index's
-- convention-specific business-day rules.  Concrete indexes can override the
-- base calculation.
fixingDate :: (GenInterestRateIndex ridx) -- ^index
 -> (Day) -- ^valueDate
 -> IO ((Day))
fixingDate a1 a2 =
  withInterestRateIndex a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  fixingDate'_ a1' a2' a3' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 296 "./QuantLib/Index/InterestRate.chs" #-}


-- |Returns the value date corresponding to a fixing date, using this index's
-- convention-specific business-day rules.  Throws when @fixingDate@ is not a
-- valid fixing day for the index.
valueDate :: (GenInterestRateIndex ridx) -- ^index
 -> (Day) -- ^fixingDate
 -> IO ((Day))
valueDate a1 a2 =
  withInterestRateIndex a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  valueDate'_ a1' a2' a3' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 303 "./QuantLib/Index/InterestRate.chs" #-}


-- |Returns the maturity date corresponding to a value date.  This is a
-- concrete-index calculation: Ibor, Libor, swap, and custom indexes can each
-- apply their own tenor, calendar, and end-of-month conventions.
maturityDate :: (GenInterestRateIndex ridx) -- ^index
 -> (Day) -- ^valueDate
 -> IO ((Day))
maturityDate a1 a2 =
  withInterestRateIndex a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  maturityDate'_ a1' a2' a3' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 310 "./QuantLib/Index/InterestRate.chs" #-}


-- |Creates one of the built-in overnight indexes (e.g. Sofr, Estr, Sonia), optionally linked to a forwarding curve.
overnightIborIndex :: (OvernightIborIndexType) -> (Maybe (GenYieldTermStructure y)) -> IO ((OvernightIborIndex))
overnightIborIndex a1 a2 =
  let {a1' = (fromIntegral . fromEnum) a1} in 
  withMaybeYieldTermStructure a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  overnightIborIndex'_ a1' a2' a3' >>= \res ->
  peekOvernightIborIndex res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 313 "./QuantLib/Index/InterestRate.chs" #-}


-- |Creates one of the built-in ISDA-fix swap-rate indexes for a given tenor, with separate forwarding and discounting curves.
liborSwapIndex :: (LiborSwapIndexType) -> ((Int,TimeUnit)) -> (Maybe (GenYieldTermStructure y1)) -- ^forwarding
 -> (Maybe (GenYieldTermStructure y2)) -- ^discounting
 -> IO ((SwapIndex))
liborSwapIndex a1 a2 a3 a4 =
  let {a1' = (fromIntegral . fromEnum) a1} in 
  let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  withMaybeYieldTermStructure a3 $ \a3' -> 
  withMaybeYieldTermStructure a4 $ \a4' -> 
  preErrorCheck $ \a5' -> 
  liborSwapIndex'_ a1' a2'1  a2'2 a3' a4' a5' >>= \res ->
  peekSwapIndex res >>= \res' ->
  errorCheck  a5'>>
  return (res')

{-# LINE 319 "./QuantLib/Index/InterestRate.chs" #-}


-- |Construct an overnight-indexed swap index. The private binding marshals
-- 'RateAveragingType' as an 'Int' to avoid a c2hs cross-module enum-import cycle.
overnightIndexedSwapIndex :: String -> (Int, TimeUnit) -> Word -> Currency
  -> OvernightIborIndex -> Bool -> RateAveragingType -> IO OvernightIndexedSwapIndex
overnightIndexedSwapIndex familyName tenr settlementDays ccy idx telescopicValueDates averagingMethod =
  overnightIndexedSwapIndex_ familyName tenr settlementDays ccy idx telescopicValueDates (fromEnum averagingMethod)

-- |Private binding for 'overnightIndexedSwapIndex'.
overnightIndexedSwapIndex_ :: (String) -> ((Int,TimeUnit)) -> (Word) -- ^settlementDays
 -> (Currency) -> (OvernightIborIndex) -> (Bool) -- ^telescopicValueDates
 -> (Int) -- ^averagingMethod
 -> IO ((OvernightIndexedSwapIndex))
overnightIndexedSwapIndex_ :: String
-> (Int, TimeUnit)
-> Word
-> Currency
-> OvernightIborIndex
-> Bool
-> Int
-> IO OvernightIndexedSwapIndex
overnightIndexedSwapIndex_ String
a1 (Int, TimeUnit)
a2 Word
a3 Currency
a4 OvernightIborIndex
a5 Bool
a6 Int
a7 =
  String
-> (Ptr CChar -> IO OvernightIndexedSwapIndex)
-> IO OvernightIndexedSwapIndex
forall a. String -> (Ptr CChar -> IO a) -> IO a
C2HSImp.withCString String
a1 ((Ptr CChar -> IO OvernightIndexedSwapIndex)
 -> IO OvernightIndexedSwapIndex)
-> (Ptr CChar -> IO OvernightIndexedSwapIndex)
-> IO OvernightIndexedSwapIndex
forall a b. (a -> b) -> a -> b
$ \Ptr CChar
a1' -> 
  let {(CInt
a2'1, CInt
a2'2) = (Int, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Int, TimeUnit)
a2} in 
  let {a3' :: CUInt
a3' = Word -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
a3} in 
  Currency
-> (Ptr CCurrency -> IO OvernightIndexedSwapIndex)
-> IO OvernightIndexedSwapIndex
forall b. Currency -> (Ptr CCurrency -> IO b) -> IO b
withCurrency Currency
a4 ((Ptr CCurrency -> IO OvernightIndexedSwapIndex)
 -> IO OvernightIndexedSwapIndex)
-> (Ptr CCurrency -> IO OvernightIndexedSwapIndex)
-> IO OvernightIndexedSwapIndex
forall a b. (a -> b) -> a -> b
$ \Ptr CCurrency
a4' -> 
  OvernightIborIndex
-> (Ptr COvernightIndex' -> IO OvernightIndexedSwapIndex)
-> IO OvernightIndexedSwapIndex
forall b.
OvernightIborIndex -> (Ptr COvernightIndex' -> IO b) -> IO b
withOvernightIborIndex OvernightIborIndex
a5 ((Ptr COvernightIndex' -> IO OvernightIndexedSwapIndex)
 -> IO OvernightIndexedSwapIndex)
-> (Ptr COvernightIndex' -> IO OvernightIndexedSwapIndex)
-> IO OvernightIndexedSwapIndex
forall a b. (a -> b) -> a -> b
$ \Ptr COvernightIndex'
a5' -> 
  let {a6' :: CInt
a6' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a6} in 
  let {a7' :: CInt
a7' = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a7} in 
  (Ptr (Ptr CChar) -> IO OvernightIndexedSwapIndex)
-> IO OvernightIndexedSwapIndex
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO OvernightIndexedSwapIndex)
 -> IO OvernightIndexedSwapIndex)
-> (Ptr (Ptr CChar) -> IO OvernightIndexedSwapIndex)
-> IO OvernightIndexedSwapIndex
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a8' -> 
  Ptr CChar
-> CInt
-> CInt
-> CUInt
-> Ptr CCurrency
-> Ptr COvernightIndex'
-> CInt
-> CInt
-> Ptr (Ptr CChar)
-> IO (Ptr COvernightIndexedSwapIndex')
overnightIndexedSwapIndex_'_ Ptr CChar
a1' CInt
a2'1  CInt
a2'2 CUInt
a3' Ptr CCurrency
a4' Ptr COvernightIndex'
a5' CInt
a6' CInt
a7' Ptr (Ptr CChar)
a8' IO (Ptr COvernightIndexedSwapIndex')
-> (Ptr COvernightIndexedSwapIndex'
    -> IO OvernightIndexedSwapIndex)
-> IO OvernightIndexedSwapIndex
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr COvernightIndexedSwapIndex'
res ->
  Ptr COvernightIndexedSwapIndex' -> IO OvernightIndexedSwapIndex
peekOvernightIndexedSwapIndex Ptr COvernightIndexedSwapIndex'
res IO OvernightIndexedSwapIndex
-> (OvernightIndexedSwapIndex -> IO OvernightIndexedSwapIndex)
-> IO OvernightIndexedSwapIndex
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \OvernightIndexedSwapIndex
res' ->
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a8'IO ()
-> IO OvernightIndexedSwapIndex -> IO OvernightIndexedSwapIndex
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  OvernightIndexedSwapIndex -> IO OvernightIndexedSwapIndex
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (OvernightIndexedSwapIndex
res')

{-# LINE 333 "./QuantLib/Index/InterestRate.chs" #-}


-- |Creates a swap-rate index whose forwarding and discounting both come from the underlying ibor index's curve.
swapIndex :: (String) -> ((Int,TimeUnit)) -> (Word) -- ^settlementDays
 -> (Currency) -> (Calendar) -> ((Int,TimeUnit)) -- ^fixedLegTenor
 -> (BusinessDayConvention) -> (DayCounter) -> (GenIborIndex ibor) -> IO ((SwapIndex))
swapIndex a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  C2HSImp.withCString a1 $ \a1' -> 
  let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  let {a3' = fromIntegral a3} in 
  withCurrency a4 $ \a4' -> 
  withCalendar a5 $ \a5' -> 
  let {(a6'1, a6'2) = fromEnumQuantity a6} in 
  let {a7' = fromEnumC a7} in 
  withDayCounter a8 $ \a8' -> 
  withIborIndex a9 $ \a9' -> 
  preErrorCheck $ \a10' -> 
  swapIndex'_ a1' a2'1  a2'2 a3' a4' a5' a6'1  a6'2 a7' a8' a9' a10' >>= \res ->
  peekSwapIndex res >>= \res' ->
  errorCheck  a10'>>
  return (res')

{-# LINE 338 "./QuantLib/Index/InterestRate.chs" #-}


-- |Creates a swap-rate index with a discounting curve distinct from the forwarding curve of the underlying ibor index.
swapIndexWithDiscountCurve :: (String) -- ^familyName
 -> ((Int,TimeUnit)) -- ^tenor
 -> (Word) -- ^settlementDays
 -> (Currency) -> (Calendar) -> ((Int,TimeUnit)) -- ^fixedLegTenor
 -> (BusinessDayConvention) -- ^fixedLegConvention
 -> (DayCounter) -- ^fixedLegDayCounter
 -> (GenIborIndex ibor) -> (GenYieldTermStructure y) -> IO ((SwapIndex))
swapIndexWithDiscountCurve a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 =
  C2HSImp.withCString a1 $ \a1' -> 
  let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  let {a3' = fromIntegral a3} in 
  withCurrency a4 $ \a4' -> 
  withCalendar a5 $ \a5' -> 
  let {(a6'1, a6'2) = fromEnumQuantity a6} in 
  let {a7' = fromEnumC a7} in 
  withDayCounter a8 $ \a8' -> 
  withIborIndex a9 $ \a9' -> 
  withYieldTermStructure a10 $ \a10' -> 
  preErrorCheck $ \a11' -> 
  swapIndexWithDiscountCurve'_ a1' a2'1  a2'2 a3' a4' a5' a6'1  a6'2 a7' a8' a9' a10' a11' >>= \res ->
  peekSwapIndex res >>= \res' ->
  errorCheck  a11'>>
  return (res')

{-# LINE 347 "./QuantLib/Index/InterestRate.chs" #-}


-- |Interest-rate index equal to @gearing1 * swapIndex1 + gearing2 * swapIndex2@.  It has no
-- native fixing history: a historical fixing is available only when both component swap indexes
-- have one.
swapSpreadIndex :: (String) -- ^familyName
 -> (GenSwapIndex sidx1) -- ^swapIndex1
 -> (GenSwapIndex sidx2) -- ^swapIndex2
 -> (Double) -- ^gearing1
 -> (Double) -- ^gearing2
 -> IO ((SwapSpreadIndex))
swapSpreadIndex a1 a2 a3 a4 a5 =
  C2HSImp.withCString a1 $ \a1' -> 
  withSwapIndex a2 $ \a2' -> 
  withSwapIndex a3 $ \a3' -> 
  let {a4' = realToFrac a4} in 
  let {a5' = realToFrac a5} in 
  preErrorCheck $ \a6' -> 
  swapSpreadIndex'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  peekSwapSpreadIndex res >>= \res' ->
  errorCheck  a6'>>
  return (res')

{-# LINE 357 "./QuantLib/Index/InterestRate.chs" #-}


-- |Low-level glue for 'iborIndex': constructs a generic Inter-Bank-Offered-Rate index, optionally linked to a forwarding curve.
qlIborIndex :: (String) -- ^familyName
 -> ((Word,TimeUnit)) -- ^tenor
 -> (Word) -- ^settlementDays
 -> (Currency) -> (Calendar) -> (BusinessDayConvention) -> (Bool) -- ^endOfMonth
 -> (DayCounter) -> (Maybe (GenYieldTermStructure y)) -> IO ((IborIndex))
qlIborIndex a1 a2 a3 a4 a5 a6 a7 a8 a9 =
  C2HSImp.withCString a1 $ \a1' -> 
  let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  let {a3' = fromIntegral a3} in 
  withCurrency a4 $ \a4' -> 
  withCalendar a5 $ \a5' -> 
  let {a6' = fromEnumC a6} in 
  let {a7' = C2HSImp.fromBool a7} in 
  withDayCounter a8 $ \a8' -> 
  withMaybeYieldTermStructure a9 $ \a9' -> 
  preErrorCheck $ \a10' -> 
  qlIborIndex'_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8' a9' a10' >>= \res ->
  peekIborIndex res >>= \res' ->
  errorCheck  a10'>>
  return (res')

{-# LINE 365 "./QuantLib/Index/InterestRate.chs" #-}


-- |Low-level glue for 'iborIndex': constructs an ICE LIBOR index (all currencies but EUR/O/N/S/N), optionally linked to a forwarding curve.
qlLibor :: (String) -- ^familyName
 -> ((Word,TimeUnit)) -> (Word) -- settlementDays
 -> (Currency) -> (Calendar) -> (DayCounter) -> (Maybe (GenYieldTermStructure y)) -> IO ((IborIndex))
qlLibor a1 a2 a3 a4 a5 a6 a7 =
  C2HSImp.withCString a1 $ \a1' -> 
  let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  let {a3' = fromIntegral a3} in 
  withCurrency a4 $ \a4' -> 
  withCalendar a5 $ \a5' -> 
  withDayCounter a6 $ \a6' -> 
  withMaybeYieldTermStructure a7 $ \a7' -> 
  preErrorCheck $ \a8' -> 
  qlLibor'_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8' >>= \res ->
  peekIborIndex res >>= \res' ->
  errorCheck  a8'>>
  return (res')

{-# LINE 370 "./QuantLib/Index/InterestRate.chs" #-}


-- |Low-level glue for 'iborIndex': constructs a one-day (O/N-S/N) ICE LIBOR index, optionally linked to a forwarding curve.
qlDailyTenorLibor :: (String) -- ^familyName
 -> (Word) -- ^settlementDays
 -> (Currency) -> (Calendar) -> (DayCounter) -> (Maybe (GenYieldTermStructure y)) -> IO ((IborIndex))
qlDailyTenorLibor a1 a2 a3 a4 a5 a6 =
  C2HSImp.withCString a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  withCurrency a3 $ \a3' -> 
  withCalendar a4 $ \a4' -> 
  withDayCounter a5 $ \a5' -> 
  withMaybeYieldTermStructure a6 $ \a6' -> 
  preErrorCheck $ \a7' -> 
  qlDailyTenorLibor'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  peekIborIndex res >>= \res' ->
  errorCheck  a7'>>
  return (res')

{-# LINE 375 "./QuantLib/Index/InterestRate.chs" #-}


-- |Low-level glue for 'iborIndex': constructs a LIBOR-like index with independently specified fixing/value/maturity calendars.
qlCustomIborIndex :: (String) -- ^familyName
 -> ((Word,TimeUnit)) -- ^tenor
 -> (Word) -- ^settlementDays
 -> (Currency) -> (Calendar) -- ^fixingCalendar
 -> (Calendar) -- ^valueCalendar
 -> (Calendar) -- ^maturityCalendar
 -> (BusinessDayConvention) -> (Bool) -- ^endOfMonth
 -> (DayCounter) -> (Maybe (GenYieldTermStructure y)) -> IO ((IborIndex))
qlCustomIborIndex a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 =
  C2HSImp.withCString a1 $ \a1' -> 
  let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  let {a3' = fromIntegral a3} in 
  withCurrency a4 $ \a4' -> 
  withCalendar a5 $ \a5' -> 
  withCalendar a6 $ \a6' -> 
  withCalendar a7 $ \a7' -> 
  let {a8' = fromEnumC a8} in 
  let {a9' = C2HSImp.fromBool a9} in 
  withDayCounter a10 $ \a10' -> 
  withMaybeYieldTermStructure a11 $ \a11' -> 
  preErrorCheck $ \a12' -> 
  qlCustomIborIndex'_ a1' a2'1  a2'2 a3' a4' a5' a6' a7' a8' a9' a10' a11' a12' >>= \res ->
  peekIborIndex res >>= \res' ->
  errorCheck  a12'>>
  return (res')

{-# LINE 386 "./QuantLib/Index/InterestRate.chs" #-}


-- |Low-level glue for 'iborIndex': constructs one of the built-in fixed-tenor/daily-tenor/overnight ibor indexes by ordinal, optionally linked to a forwarding curve.
qlCreateIbor :: (Int) -> ((Word,TimeUnit)) -> (Maybe (GenYieldTermStructure y)) -> IO ((IborIndex))
qlCreateIbor a1 a2 a3 =
  let {a1' = fromIntegral a1} in 
  let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  withMaybeYieldTermStructure a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  qlCreateIbor'_ a1' a2'1  a2'2 a3' a4' >>= \res ->
  peekIborIndex res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 389 "./QuantLib/Index/InterestRate.chs" #-}


-- |Creates a generic overnight index, optionally linked to a forwarding curve.
overnightIndex :: (String) -> (Word) -- ^settlementDays
 -> (Currency) -> (Calendar) -> (DayCounter) -> (Maybe (GenYieldTermStructure y)) -> IO ((OvernightIborIndex))
overnightIndex a1 a2 a3 a4 a5 a6 =
  C2HSImp.withCString a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  withCurrency a3 $ \a3' -> 
  withCalendar a4 $ \a4' -> 
  withDayCounter a5 $ \a5' -> 
  withMaybeYieldTermStructure a6 $ \a6' -> 
  preErrorCheck $ \a7' -> 
  overnightIndex'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
  peekOvernightIborIndex res >>= \res' ->
  errorCheck  a7'>>
  return (res')

{-# LINE 393 "./QuantLib/Index/InterestRate.chs" #-}


-- |Returns the business day convention used to adjust the index's value/maturity dates.
businessDayConvention :: (GenIborIndex ibor) -> (BusinessDayConvention)
businessDayConvention a1 =
  C2HSImp.unsafePerformIO $
  withIborIndex a1 $ \a1' -> 
  businessDayConvention'_ a1' >>= \res ->
  let {res' = toEnumC res} in
  return (res')

{-# LINE 396 "./QuantLib/Index/InterestRate.chs" #-}


-- |Returns whether the index's date calculations roll to the end of the month.
endOfMonth :: (GenIborIndex ibor) -> (Bool)
endOfMonth a1 =
  C2HSImp.unsafePerformIO $
  withIborIndex a1 $ \a1' -> 
  endOfMonth'_ a1' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  return (res')

{-# LINE 399 "./QuantLib/Index/InterestRate.chs" #-}


-- |Returns the overnight-indexed swap underlying the index for a given fixing date. Relinking the index's term structure afterwards has no effect on the returned swap.
underlyingOis :: (OvernightIndexedSwapIndex) -> (Day) -> IO ((OvernightIndexedSwap))
underlyingOis a1 a2 =
  withOvernightIndexedSwapIndex a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  underlyingOis'_ a1' a2' a3' >>= \res ->
  peekOvernightIndexedSwap res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 402 "./QuantLib/Index/InterestRate.chs" #-}


-- |Returns the vanilla swap underlying the index for a given fixing date. Relinking the index's term structure afterwards has no effect on the returned swap.
underlyingSwap :: (GenSwapIndex sidx) -> (Day) -> IO ((VanillaSwap))
underlyingSwap a1 a2 =
  withSwapIndex a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  underlyingSwap'_ a1' a2' a3' >>= \res ->
  peekVanillaSwap res >>= \res' ->
  errorCheck  a3'>>
  return (res')

{-# LINE 405 "./QuantLib/Index/InterestRate.chs" #-}


-- |Convenience wrapper: 'historicalIndexAnalysis' specialised to interest-rate indexes.
historicalRatesAnalysis :: Day -> Day -> (Int, TimeUnit) -> NonEmpty (GenInterestRateIndex ridx) -> IO HistoricalIndexAnalysis
historicalRatesAnalysis startDate endDate step ridxs =
  mapM asIndex (toList ridxs) >>= historicalIndexAnalysis startDate endDate step

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

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlBMAIndex"
  bmaIndex'_ :: ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CBMAIndex')))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlBMAIndexFixingSchedule"
  fixingSchedule'_ :: ((C2HSImp.Ptr (CBMAIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSchedule)))))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlInterestRateIndexForecastFixing"
  forecastFixing'_ :: ((C2HSImp.Ptr (CInterestRateIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlInterestRateIndexCurrency"
  currency'_ :: ((C2HSImp.Ptr (CInterestRateIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCurrency)))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlInterestRateIndexDayCounter"
  dayCounter'_ :: ((C2HSImp.Ptr (CInterestRateIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CDayCounter)))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlInterestRateIndexFixingDays"
  fixingDays'_ :: ((C2HSImp.Ptr (CInterestRateIndex')) -> (IO C2HSImp.CUInt))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlInterestRateIndexTenor"
  tenor'_ :: ((C2HSImp.Ptr (CInterestRateIndex')) -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlInterestRateIndexFixingDate"
  fixingDate'_ :: ((C2HSImp.Ptr (CInterestRateIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlInterestRateIndexValueDate"
  valueDate'_ :: ((C2HSImp.Ptr (CInterestRateIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlInterestRateIndexMaturityDate"
  maturityDate'_ :: ((C2HSImp.Ptr (CInterestRateIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlCreateONIndex"
  overnightIborIndex'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COvernightIndex'))))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlCreateLiborSwapIndex"
  liborSwapIndex'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwapIndex')))))))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlOvernightIndexedSwapIndex"
  overnightIndexedSwapIndex_'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (COvernightIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COvernightIndexedSwapIndex'))))))))))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlSwapIndex"
  swapIndex'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwapIndex')))))))))))))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlSwapIndex1"
  swapIndexWithDiscountCurve'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CIborIndex')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwapIndex'))))))))))))))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlSwapSpreadIndex"
  swapSpreadIndex'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr (CSwapIndex')) -> ((C2HSImp.Ptr (CSwapIndex')) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CSwapSpreadIndex')))))))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlIborIndex"
  qlIborIndex'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CIborIndex'))))))))))))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlLibor"
  qlLibor'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CIborIndex'))))))))))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlDailyTenorLibor"
  qlDailyTenorLibor'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CIborIndex'))))))))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlCustomIborIndex"
  qlCustomIborIndex'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CIborIndex'))))))))))))))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlCreateIbor"
  qlCreateIbor'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CIborIndex'))))))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlOvernightIndex"
  overnightIndex'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CDayCounter)) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COvernightIndex'))))))))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlIborIndexBusinessDayConvention"
  businessDayConvention'_ :: ((C2HSImp.Ptr (CIborIndex')) -> (IO C2HSImp.CInt))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlIborIndexEndOfMonth"
  endOfMonth'_ :: ((C2HSImp.Ptr (CIborIndex')) -> (IO C2HSImp.CInt))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlOvernightIndexedSwapIndexUnderlyingSwap"
  underlyingOis'_ :: ((C2HSImp.Ptr (COvernightIndexedSwapIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (COvernightIndexedSwap'))))))

foreign import ccall safe "QuantLib/Index/InterestRate.chs.h qlSwapIndexUnderlyingSwap"
  underlyingSwap'_ :: ((C2HSImp.Ptr (CSwapIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CVanillaSwap'))))))