never executed always true always false
    1 -- GENERATED by C->Haskell Compiler, version 0.28.8 Switcheroo, 25 November 2017 (Haskell)
    2 -- Edit the ORIGNAL .chs file instead!
    3 
    4 
    5 module QuantLib.Instrument.Energy
    6   (
    7     -- * Types
    8     -- ** Commodity instrument hierarchy
    9     GenCommodity
   10   , Commodity
   11   , GenEnergyCommodity
   12   , EnergyCommodity
   13   , GenEnergySwap
   14   , EnergySwap
   15   , EnergyFuture
   16   , EnergyVanillaSwap
   17   , EnergyBasisSwap
   18 
   19     -- ** Costs, errors and positions
   20   , SecondaryCosts
   21   , SecondaryCostAmounts
   22   , PricingErrorLevel(..)
   23   , PricingError(..)
   24   , PricingErrors
   25   , EnergyDailyPosition(..)
   26   , EnergyDailyPositions
   27   , CommodityCashFlow
   28   , CommodityCashFlows
   29 
   30     -- ** Configuration
   31   , DeliverySchedule(..)
   32   , QuantityPeriodicity(..)
   33 
   34     -- * Constructors
   35   , energyFuture
   36   , energyVanillaSwap
   37   , energyBasisSwap
   38   , createPricingPeriods
   39 
   40     -- * Mutators
   41   , addPricingError
   42 
   43     -- * Inspectors
   44   , discountedAmount
   45   , undiscountedAmount
   46   , discountedPaymentAmount
   47   , undiscountedPaymentAmount
   48   , discountFactor
   49   , paymentDiscountFactor
   50   , finalized
   51   , secondaryCostAmounts
   52   , pricingErrors
   53   , quantity
   54   , dailyPositions
   55   , paymentCashFlows
   56   ) where
   57 import qualified Foreign.C.String as C2HSImp
   58 import qualified Foreign.C.Types as C2HSImp
   59 import qualified Foreign.ForeignPtr as C2HSImp
   60 import qualified Foreign.Marshal.Utils as C2HSImp
   61 import qualified Foreign.Ptr as C2HSImp
   62 import qualified System.IO.Unsafe as C2HSImp
   63 
   64 
   65 import QuantLib.Internal
   66 import QuantLib.Internal.Type
   67 import QuantLib.Internal.Common
   68 import QuantLib.Commodity
   69 import Foreign.Marshal.Alloc(alloca)
   70 import Foreign.Marshal.Utils(fromBool)
   71 
   72 
   73 
   74 
   75 
   76 
   77 
   78 
   79 
   80 
   81 
   82 
   83 
   84 
   85 
   86 
   87 
   88 
   89 
   90 
   91 
   92 
   93 
   94 
   95 
   96 
   97 
   98 
   99 
  100 
  101 
  102 
  103 
  104 
  105 
  106 
  107 -- |QuantLib's @map<string, ext::any>@, used with exactly two concrete alternatives across the
  108 -- module (@CommodityUnitCost@\/@Money@, confirmed from @energycommodity.cpp@'s two @any_cast@
  109 -- branches) -- bound as a real 2-variant sum rather than a generic @any@. Passed optionally to
  110 -- every energy-instrument constructor below; @[]@ stands in for upstream's null @shared_ptr@.
  111 type SecondaryCosts = [(String, Either CommodityUnitCost (Double, Currency))]
  112 
  113 -- |The computed, currency-resolved output of 'SecondaryCosts' -- @Commodity::secondaryCostAmounts()@,
  114 -- a @map<string, Money>@.
  115 type SecondaryCostAmounts = [(String, (Double, Currency))]
  116 
  117 -- |A single entry of 'PricingErrors' -- @tradeId@ is never set by any constructor path that
  118 -- reaches 'addPricingError' (upstream's own call sites all default it to empty), so it isn't
  119 -- bound.
  120 data PricingError = PricingError
  121   { pricingErrorLevel :: PricingErrorLevel
  122   , pricingErrorMessage :: String
  123   , pricingErrorDetail :: String
  124   } deriving (Show, Eq)
  125 
  126 type PricingErrors = [PricingError]
  127 
  128 -- |One day's position detail from an 'EnergySwap' leaf's @dailyPositions()@ -- a flat record
  129 -- rather than a @(Day, ...)@ pair, since 'edpDate' already carries the map key.
  130 data EnergyDailyPosition = EnergyDailyPosition
  131   { edpDate :: Day
  132   , edpQuantityAmount :: Double
  133   , edpPayLegPrice :: Double
  134   , edpReceiveLegPrice :: Double
  135   , edpRiskDelta :: Double
  136   , edpUnrealized :: Bool
  137   } deriving (Show, Eq)
  138 
  139 type EnergyDailyPositions = [EnergyDailyPosition]
  140 
  141 type CommodityCashFlows = [CommodityCashFlow]
  142 
  143 -- |The discounted amount, in the global commodity base currency ('QuantLib.Commodity.commoditySettingsCurrency').
  144 --
  145 -- Not 'pure': the shim's own @ret(new Currency(...))@ is a 'bad_alloc'-only throw point, and letting
  146 -- a C++ exception unwind across the FFI boundary from an 'unsafePerformIO'-backed pure binding is
  147 -- undefined behavior, so this needs the same 'char **e'\/'preErrorCheck' error channel as any other
  148 -- throwing call.
  149 discountedAmount :: (CommodityCashFlow) -> IO ((Double), (Currency))
  150 discountedAmount a1 =
  151   withCommodityCashFlow a1 $ \a1' -> 
  152   alloca $ \a2' -> 
  153   preErrorCheck $ \a3' -> 
  154   discountedAmount'_ a1' a2' a3' >>= \res ->
  155   let {res' = realToFrac res} in
  156   peekCurrencyPtr  a2'>>= \a2'' -> 
  157   errorCheck  a3'>>
  158   return (res', a2'')
  159 
  160 
  161 
  162 -- |As 'discountedAmount', without the discount factor applied.
  163 undiscountedAmount :: (CommodityCashFlow) -> IO ((Double), (Currency))
  164 undiscountedAmount a1 =
  165   withCommodityCashFlow a1 $ \a1' -> 
  166   alloca $ \a2' -> 
  167   preErrorCheck $ \a3' -> 
  168   undiscountedAmount'_ a1' a2' a3' >>= \res ->
  169   let {res' = realToFrac res} in
  170   peekCurrencyPtr  a2'>>= \a2'' -> 
  171   errorCheck  a3'>>
  172   return (res', a2'')
  173 
  174 
  175 
  176 -- |The discounted amount, in the payment (leg) currency.
  177 discountedPaymentAmount :: (CommodityCashFlow) -> IO ((Double), (Currency))
  178 discountedPaymentAmount a1 =
  179   withCommodityCashFlow a1 $ \a1' -> 
  180   alloca $ \a2' -> 
  181   preErrorCheck $ \a3' -> 
  182   discountedPaymentAmount'_ a1' a2' a3' >>= \res ->
  183   let {res' = realToFrac res} in
  184   peekCurrencyPtr  a2'>>= \a2'' -> 
  185   errorCheck  a3'>>
  186   return (res', a2'')
  187 
  188 
  189 
  190 -- |As 'discountedPaymentAmount', without the discount factor applied.
  191 undiscountedPaymentAmount :: (CommodityCashFlow) -> IO ((Double), (Currency))
  192 undiscountedPaymentAmount a1 =
  193   withCommodityCashFlow a1 $ \a1' -> 
  194   alloca $ \a2' -> 
  195   preErrorCheck $ \a3' -> 
  196   undiscountedPaymentAmount'_ a1' a2' a3' >>= \res ->
  197   let {res' = realToFrac res} in
  198   peekCurrencyPtr  a2'>>= \a2'' -> 
  199   errorCheck  a3'>>
  200   return (res', a2'')
  201 
  202 
  203 
  204 -- |The discount factor applied to the base-currency amount.
  205 discountFactor :: (CommodityCashFlow) -> (Double)
  206 discountFactor a1 =
  207   C2HSImp.unsafePerformIO $
  208   withCommodityCashFlow a1 $ \a1' -> 
  209   discountFactor'_ a1' >>= \res ->
  210   let {res' = realToFrac res} in
  211   return (res')
  212 
  213 
  214 
  215 -- |The discount factor applied to the payment-currency amount.
  216 paymentDiscountFactor :: (CommodityCashFlow) -> (Double)
  217 paymentDiscountFactor a1 =
  218   C2HSImp.unsafePerformIO $
  219   withCommodityCashFlow a1 $ \a1' -> 
  220   paymentDiscountFactor'_ a1' >>= \res ->
  221   let {res' = realToFrac res} in
  222   return (res')
  223 
  224 
  225 
  226 -- |Whether this cash flow's payment date has already occurred as of the evaluation date.
  227 finalized :: (CommodityCashFlow) -> (Bool)
  228 finalized a1 =
  229   C2HSImp.unsafePerformIO $
  230   withCommodityCashFlow a1 $ \a1' -> 
  231   finalized'_ a1' >>= \res ->
  232   let {res' = C2HSImp.toBool res} in
  233   return (res')
  234 
  235 
  236 
  237 -- |Record a pricing diagnostic against a 'Commodity'\/'EnergyCommodity' leaf (any of 'EnergyFuture',
  238 -- 'EnergyVanillaSwap', 'EnergyBasisSwap'), retrievable afterwards via 'pricingErrors'. Mirrors
  239 -- upstream's own default empty @detail@ with a plain @\"\"@ argument.
  240 addPricingError :: (GenCommodity c) -> (PricingErrorLevel) -> (String) -> (String) -> IO ()
  241 addPricingError a1 a2 a3 a4 =
  242   withCommodity a1 $ \a1' -> 
  243   let {a2' = fromEnumC a2} in 
  244   C2HSImp.withCString a3 $ \a3' -> 
  245   C2HSImp.withCString a4 $ \a4' -> 
  246   addPricingError'_ a1' a2' a3' a4' >>
  247   return ()
  248 
  249 
  250 
  251 qlCommoditySecondaryCostAmounts_ :: (GenCommodity c) -> IO (([String]), ([Double]), ([Currency]))
  252 qlCommoditySecondaryCostAmounts_ a1 =
  253   withCommodity a1 $ \a1' -> 
  254   preCStringArray $ \(a2'1, a2'2) -> 
  255   preDoubleArray $ \(a3'1, a3'2) -> 
  256   preCurrencyArray $ \(a4'1, a4'2) -> 
  257   preErrorCheck $ \a5' -> 
  258   qlCommoditySecondaryCostAmounts_'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5' >>
  259   peekCStringArray  a2'1  a2'2>>= \a2'' -> 
  260   peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  261   peekCurrencyArray  a4'1  a4'2>>= \a4'' -> 
  262   errorCheck  a5'>>
  263   return (a2'', a3'', a4'')
  264 
  265 
  266 
  267 -- |The currency-resolved secondary costs computed during the most recent pricing
  268 -- (@performCalculations()@) of this 'Commodity'\/'EnergyCommodity' leaf -- a plain member read, not
  269 -- itself a pricing trigger, so call 'QuantLib.Instrument.npvWithZSpread first if it hasn't been priced yet.
  270 secondaryCostAmounts :: GenCommodity c -> IO SecondaryCostAmounts
  271 secondaryCostAmounts o = do
  272   (keys, amts, ccys) <- qlCommoditySecondaryCostAmounts_ o
  273   pure $ zip keys (zip amts ccys)
  274 
  275 qlCommodityPricingErrors_ :: (GenCommodity c) -> IO (([PricingErrorLevel]), ([String]), ([String]))
  276 qlCommodityPricingErrors_ a1 =
  277   withCommodity a1 $ \a1' -> 
  278   preIntArray $ \(a2'1, a2'2) -> 
  279   preCStringArray $ \(a3'1, a3'2) -> 
  280   preCStringArray $ \(a4'1, a4'2) -> 
  281   preErrorCheck $ \a5' -> 
  282   qlCommodityPricingErrors_'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5' >>
  283   peekPricingErrorLevelArray  a2'1  a2'2>>= \a2'' -> 
  284   peekCStringArray  a3'1  a3'2>>= \a3'' -> 
  285   peekCStringArray  a4'1  a4'2>>= \a4'' -> 
  286   errorCheck  a5'>>
  287   return (a2'', a3'', a4'')
  288 
  289 
  290 
  291 -- |Every pricing diagnostic recorded so far (via upstream's own internal calls, or via
  292 -- 'addPricingError') against this 'Commodity'\/'EnergyCommodity' leaf.
  293 pricingErrors :: GenCommodity c -> IO PricingErrors
  294 pricingErrors o = do
  295   (levels, errs, details) <- qlCommodityPricingErrors_ o
  296   pure $ zipWith3 PricingError levels errs details
  297 
  298 qlEnergyCommodityQuantity_ :: (GenEnergyCommodity e) -> IO ((Double), (CommodityType), (UnitOfMeasure))
  299 qlEnergyCommodityQuantity_ a1 =
  300   withEnergyCommodity a1 $ \a1' -> 
  301   alloca $ \a2' -> 
  302   alloca $ \a3' -> 
  303   preErrorCheck $ \a4' -> 
  304   qlEnergyCommodityQuantity_'_ a1' a2' a3' a4' >>= \res ->
  305   let {res' = realToFrac res} in
  306   peekCommodityTypePtr  a2'>>= \a2'' -> 
  307   peekUnitOfMeasurePtr  a3'>>= \a3'' -> 
  308   errorCheck  a4'>>
  309   return (res', a2'', a3'')
  310 
  311 
  312 
  313 -- |The commodity quantity of this 'EnergyCommodity' leaf -- either the plain quantity given at
  314 -- construction ('EnergyFuture') or the sum across every 'PricingPeriod' ('EnergySwap' and its
  315 -- leaves, a real computed sum -- see @energyswap.cpp@). One binding covers both, dispatched
  316 -- virtually on the C++ side.
  317 quantity :: GenEnergyCommodity e -> IO Quantity
  318 quantity o = do
  319   (amt, ct, uom) <- qlEnergyCommodityQuantity_ o
  320   pure (ct, uom, amt)
  321 
  322 -- |Construct an energy future: a single mark-to-market position against a 'CommodityIndex',
  323 -- struck at a fixed 'CommodityUnitCost' trade price. @buySell@ is a signed multiplier (@1@ to buy,
  324 -- @-1@ to sell), matching upstream's own @Integer buySell@ (not a @Bool@). @tradePrice@\/@index@
  325 -- are not exposed as getters because they only echo these constructor arguments.
  326 energyFuture :: Int -- ^buySell
  327              -> Quantity
  328              -> CommodityUnitCost -- ^tradePrice
  329              -> CommodityIndex
  330              -> CommodityType
  331              -> SecondaryCosts
  332              -> IO EnergyFuture
  333 energyFuture buySell (qCt, qUom, qAmt) (tpAmt, tpCcy, tpUom) index cmdType secCosts =
  334   qlEnergyFuture_ buySell qCt qUom qAmt tpAmt tpCcy tpUom index cmdType
  335     scKeys scIsUnitCost scAmts scCcys scUoms
  336   where (scKeys, scIsUnitCost, scAmts, scCcys, scUoms) = secondaryCostsFields secCosts
  337 
  338 qlEnergyFuture_ :: (Int) -> (CommodityType) -> (UnitOfMeasure) -> (Double) -> (Double) -> (Currency) -> (UnitOfMeasure) -> (CommodityIndex) -> (CommodityType) -> ([String]) -> ([Bool]) -> ([Double]) -> ([Currency]) -> ([Maybe UnitOfMeasure]) -> IO ((EnergyFuture))
  339 qlEnergyFuture_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 =
  340   let {a1' = fromIntegral a1} in 
  341   withCommodityType a2 $ \a2' -> 
  342   withUnitOfMeasure a3 $ \a3' -> 
  343   let {a4' = realToFrac a4} in 
  344   let {a5' = realToFrac a5} in 
  345   withCurrency a6 $ \a6' -> 
  346   withUnitOfMeasure a7 $ \a7' -> 
  347   withCommodityIndex a8 $ \a8' -> 
  348   withCommodityType a9 $ \a9' -> 
  349   withStringArray a10 $ \(a10'1, a10'2) -> 
  350   withBoolArray a11 $ \(a11'1, a11'2) -> 
  351   withDoubleArray a12 $ \(a12'1, a12'2) -> 
  352   withCurrencyArray a13 $ \(a13'1, a13'2) -> 
  353   withMaybeUnitOfMeasureArray a14 $ \(a14'1, a14'2) -> 
  354   preErrorCheck $ \a15' -> 
  355   qlEnergyFuture_'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' a10'1  a10'2 a11'1  a11'2 a12'1  a12'2 a13'1  a13'2 a14'1  a14'2 a15' >>= \res ->
  356   peekEnergyFuture res >>= \res' ->
  357   errorCheck  a15'>>
  358   return (res')
  359 
  360 
  361 
  362 qlEnergySwapDailyPositions_ :: (GenEnergySwap s) -> IO (([Day]), ([Double]), ([Double]), ([Double]), ([Double]), ([Bool]))
  363 qlEnergySwapDailyPositions_ a1 =
  364   withEnergySwap a1 $ \a1' -> 
  365   preIntArray $ \(a2'1, a2'2) -> 
  366   preDoubleArray $ \(a3'1, a3'2) -> 
  367   preDoubleArray $ \(a4'1, a4'2) -> 
  368   preDoubleArray $ \(a5'1, a5'2) -> 
  369   preDoubleArray $ \(a6'1, a6'2) -> 
  370   preIntArray $ \(a7'1, a7'2) -> 
  371   preErrorCheck $ \a8' -> 
  372   qlEnergySwapDailyPositions_'_ a1' a2'1  a2'2 a3'1  a3'2 a4'1  a4'2 a5'1  a5'2 a6'1  a6'2 a7'1  a7'2 a8' >>
  373   peekDayArray  a2'1  a2'2>>= \a2'' -> 
  374   peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  375   peekDoubleArray  a4'1  a4'2>>= \a4'' -> 
  376   peekDoubleArray  a5'1  a5'2>>= \a5'' -> 
  377   peekDoubleArray  a6'1  a6'2>>= \a6'' -> 
  378   peekBoolArray  a7'1  a7'2>>= \a7'' -> 
  379   errorCheck  a8'>>
  380   return (a2'', a3'', a4'', a5'', a6'', a7'')
  381 
  382 
  383 
  384 -- |The per-day pricing breakdown computed during this 'EnergySwap' leaf's most recent
  385 -- @performCalculations()@ -- populated only after pricing (call 'QuantLib.Instrument.npvWithZSpread first).
  386 dailyPositions :: GenEnergySwap s -> IO EnergyDailyPositions
  387 dailyPositions s = do
  388   (dates, qtyAmts, payPrices, recvPrices, riskDeltas, unrealized) <- qlEnergySwapDailyPositions_ s
  389   pure $ zipWith6 EnergyDailyPosition dates qtyAmts payPrices recvPrices riskDeltas unrealized
  390 
  391 -- |The realized\/unrealized payment cash flows computed during this 'EnergySwap' leaf's most
  392 -- recent @performCalculations()@ -- populated only after pricing.
  393 paymentCashFlows :: (GenEnergySwap s) -> IO (([CommodityCashFlow]))
  394 paymentCashFlows a1 =
  395   withEnergySwap a1 $ \a1' -> 
  396   preCommodityCashFlowArray $ \(a2'1, a2'2) -> 
  397   preErrorCheck $ \a3' -> 
  398   paymentCashFlows'_ a1' a2'1  a2'2 a3' >>
  399   peekCommodityCashFlowArray  a2'1  a2'2>>= \a2'' -> 
  400   errorCheck  a3'>>
  401   return (a2'')
  402 
  403 
  404 
  405 -- |Split a 'SecondaryCosts' list into the five parallel arrays every energy-instrument
  406 -- constructor's C shim consumes it as (keys, is-a-'CommodityUnitCost'-flag, amounts, currencies,
  407 -- units-of-measure -- 'Nothing' for a plain 'Money' entry).
  408 secondaryCostsFields :: SecondaryCosts -> ([String], [Bool], [Double], [Currency], [Maybe UnitOfMeasure])
  409 secondaryCostsFields entries =
  410   ( map fst entries
  411   , map (either (const True) (const False) . snd) entries
  412   , map (either (\(a,_,_) -> a) fst . snd) entries
  413   , map (either (\(_,c,_) -> c) snd . snd) entries
  414   , map (either (\(_,_,u) -> Just u) (const Nothing) . snd) entries
  415   )
  416 
  417 -- |Split a 'PricingPeriods' list into the six parallel arrays every energy-swap constructor's C
  418 -- shim consumes it as (start dates, end dates, payment dates, quantity commodity types, quantity
  419 -- units of measure, quantity amounts).
  420 pricingPeriodsFields :: PricingPeriods -> ([Day], [Day], [Day], [CommodityType], [UnitOfMeasure], [Double])
  421 pricingPeriodsFields pps =
  422   ( map pricingPeriodStartDate pps
  423   , map pricingPeriodEndDate pps
  424   , map pricingPeriodPaymentDate pps
  425   , map (\(t,_,_) -> t) qtys
  426   , map (\(_,u,_) -> u) qtys
  427   , map (\(_,_,a) -> a) qtys
  428   )
  429   where qtys = map pricingPeriodQuantity pps
  430 
  431 -- |Construct a vanilla energy swap: fixed 'CommodityUnitCost' price against a floating
  432 -- 'CommodityIndex' quote, over one or more 'PricingPeriod's. @payer@ selects which leg (fixed or
  433 -- floating) is paid. @payReceive@\/@fixedPrice@\/@fixedPriceUnitOfMeasure@\/@index@ are not bound
  434 -- as getters because they only echo this constructor's arguments; @payReceive@ is simply
  435 -- @if payer then 1 else 0@.
  436 energyVanillaSwap :: Bool -- ^payer
  437                   -> Calendar
  438                   -> (Double, Currency) -- ^fixedPrice
  439                   -> UnitOfMeasure -- ^fixedPriceUnitOfMeasure
  440                   -> CommodityIndex
  441                   -> Currency -- ^payCurrency
  442                   -> Currency -- ^receiveCurrency
  443                   -> PricingPeriods
  444                   -> CommodityType
  445                   -> SecondaryCosts
  446                   -> GenYieldTermStructure y1 -- ^payLegTermStructure
  447                   -> GenYieldTermStructure y2 -- ^receiveLegTermStructure
  448                   -> GenYieldTermStructure y3 -- ^discountTermStructure
  449                   -> IO EnergyVanillaSwap
  450 energyVanillaSwap payer calendar (fpAmt, fpCcy) fpUom index payCcy receiveCcy pps cmdType secCosts
  451                   payLegTS receiveLegTS discountTS =
  452   qlEnergyVanillaSwap_ payer calendar fpAmt fpCcy fpUom index payCcy receiveCcy
  453     ppStarts ppEnds ppPays ppTypes ppUoms ppAmts
  454     cmdType scKeys scIsUnitCost scAmts scCcys scUoms
  455     payLegTS receiveLegTS discountTS
  456   where
  457     (ppStarts, ppEnds, ppPays, ppTypes, ppUoms, ppAmts) = pricingPeriodsFields pps
  458     (scKeys, scIsUnitCost, scAmts, scCcys, scUoms) = secondaryCostsFields secCosts
  459 
  460 qlEnergyVanillaSwap_ :: (Bool) -> (Calendar) -> (Double) -> (Currency) -> (UnitOfMeasure) -> (CommodityIndex) -> (Currency) -> (Currency) -> ([Day]) -> ([Day]) -> ([Day]) -> ([CommodityType]) -> ([UnitOfMeasure]) -> ([Double]) -> (CommodityType) -> ([String]) -> ([Bool]) -> ([Double]) -> ([Currency]) -> ([Maybe UnitOfMeasure]) -> (GenYieldTermStructure y1) -> (GenYieldTermStructure y2) -> (GenYieldTermStructure y3) -> IO ((EnergyVanillaSwap))
  461 qlEnergyVanillaSwap_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 =
  462   let {a1' = fromBool a1} in 
  463   withCalendar a2 $ \a2' -> 
  464   let {a3' = realToFrac a3} in 
  465   withCurrency a4 $ \a4' -> 
  466   withUnitOfMeasure a5 $ \a5' -> 
  467   withCommodityIndex a6 $ \a6' -> 
  468   withCurrency a7 $ \a7' -> 
  469   withCurrency a8 $ \a8' -> 
  470   withDayArray a9 $ \(a9'1, a9'2) -> 
  471   withDayArray a10 $ \(a10'1, a10'2) -> 
  472   withDayArray a11 $ \(a11'1, a11'2) -> 
  473   withCommodityTypeArray a12 $ \(a12'1, a12'2) -> 
  474   withUnitOfMeasureArray a13 $ \(a13'1, a13'2) -> 
  475   withDoubleArray a14 $ \(a14'1, a14'2) -> 
  476   withCommodityType a15 $ \a15' -> 
  477   withStringArray a16 $ \(a16'1, a16'2) -> 
  478   withBoolArray a17 $ \(a17'1, a17'2) -> 
  479   withDoubleArray a18 $ \(a18'1, a18'2) -> 
  480   withCurrencyArray a19 $ \(a19'1, a19'2) -> 
  481   withMaybeUnitOfMeasureArray a20 $ \(a20'1, a20'2) -> 
  482   withYieldTermStructure a21 $ \a21' -> 
  483   withYieldTermStructure a22 $ \a22' -> 
  484   withYieldTermStructure a23 $ \a23' -> 
  485   preErrorCheck $ \a24' -> 
  486   qlEnergyVanillaSwap_'_ a1' a2' a3' a4' a5' a6' a7' a8' a9'1  a9'2 a10'1  a10'2 a11'1  a11'2 a12'1  a12'2 a13'1  a13'2 a14'1  a14'2 a15' a16'1  a16'2 a17'1  a17'2 a18'1  a18'2 a19'1  a19'2 a20'1  a20'2 a21' a22' a23' a24' >>= \res ->
  487   peekEnergyVanillaSwap res >>= \res' ->
  488   errorCheck  a24'>>
  489   return (res')
  490 
  491 
  492 
  493 -- |Construct an energy basis swap: two floating 'CommodityIndex' legs (pay\/receive), one of them
  494 -- offset by a fixed 'CommodityUnitCost' basis, over one or more 'PricingPeriod's. @spreadToPayLeg@
  495 -- selects which leg the basis is added to. @payIndex@\/@receiveIndex@\/@basis@ are not bound as
  496 -- getters -- all are plain, never-mutated echoes of this constructor's own arguments.
  497 energyBasisSwap :: Calendar
  498                 -> CommodityIndex -- ^spreadIndex
  499                 -> CommodityIndex -- ^payIndex
  500                 -> CommodityIndex -- ^receiveIndex
  501                 -> Bool -- ^spreadToPayLeg
  502                 -> Currency -- ^payCurrency
  503                 -> Currency -- ^receiveCurrency
  504                 -> PricingPeriods
  505                 -> CommodityUnitCost -- ^basis
  506                 -> CommodityType
  507                 -> SecondaryCosts
  508                 -> GenYieldTermStructure y1 -- ^payLegTermStructure
  509                 -> GenYieldTermStructure y2 -- ^receiveLegTermStructure
  510                 -> GenYieldTermStructure y3 -- ^discountTermStructure
  511                 -> IO EnergyBasisSwap
  512 energyBasisSwap calendar spreadIndex payIndex receiveIndex spreadToPayLeg payCcy receiveCcy pps
  513                 (basisAmt, basisCcy, basisUom) cmdType secCosts payLegTS receiveLegTS discountTS =
  514   qlEnergyBasisSwap_ calendar spreadIndex payIndex receiveIndex spreadToPayLeg payCcy receiveCcy
  515     ppStarts ppEnds ppPays ppTypes ppUoms ppAmts
  516     basisAmt basisCcy basisUom
  517     cmdType scKeys scIsUnitCost scAmts scCcys scUoms
  518     payLegTS receiveLegTS discountTS
  519   where
  520     (ppStarts, ppEnds, ppPays, ppTypes, ppUoms, ppAmts) = pricingPeriodsFields pps
  521     (scKeys, scIsUnitCost, scAmts, scCcys, scUoms) = secondaryCostsFields secCosts
  522 
  523 qlEnergyBasisSwap_ :: (Calendar) -> (CommodityIndex) -> (CommodityIndex) -> (CommodityIndex) -> (Bool) -> (Currency) -> (Currency) -> ([Day]) -> ([Day]) -> ([Day]) -> ([CommodityType]) -> ([UnitOfMeasure]) -> ([Double]) -> (Double) -> (Currency) -> (UnitOfMeasure) -> (CommodityType) -> ([String]) -> ([Bool]) -> ([Double]) -> ([Currency]) -> ([Maybe UnitOfMeasure]) -> (GenYieldTermStructure y1) -> (GenYieldTermStructure y2) -> (GenYieldTermStructure y3) -> IO ((EnergyBasisSwap))
  524 qlEnergyBasisSwap_ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 =
  525   withCalendar a1 $ \a1' -> 
  526   withCommodityIndex a2 $ \a2' -> 
  527   withCommodityIndex a3 $ \a3' -> 
  528   withCommodityIndex a4 $ \a4' -> 
  529   let {a5' = fromBool a5} in 
  530   withCurrency a6 $ \a6' -> 
  531   withCurrency a7 $ \a7' -> 
  532   withDayArray a8 $ \(a8'1, a8'2) -> 
  533   withDayArray a9 $ \(a9'1, a9'2) -> 
  534   withDayArray a10 $ \(a10'1, a10'2) -> 
  535   withCommodityTypeArray a11 $ \(a11'1, a11'2) -> 
  536   withUnitOfMeasureArray a12 $ \(a12'1, a12'2) -> 
  537   withDoubleArray a13 $ \(a13'1, a13'2) -> 
  538   let {a14' = realToFrac a14} in 
  539   withCurrency a15 $ \a15' -> 
  540   withUnitOfMeasure a16 $ \a16' -> 
  541   withCommodityType a17 $ \a17' -> 
  542   withStringArray a18 $ \(a18'1, a18'2) -> 
  543   withBoolArray a19 $ \(a19'1, a19'2) -> 
  544   withDoubleArray a20 $ \(a20'1, a20'2) -> 
  545   withCurrencyArray a21 $ \(a21'1, a21'2) -> 
  546   withMaybeUnitOfMeasureArray a22 $ \(a22'1, a22'2) -> 
  547   withYieldTermStructure a23 $ \a23' -> 
  548   withYieldTermStructure a24 $ \a24' -> 
  549   withYieldTermStructure a25 $ \a25' -> 
  550   preErrorCheck $ \a26' -> 
  551   qlEnergyBasisSwap_'_ a1' a2' a3' a4' a5' a6' a7' a8'1  a8'2 a9'1  a9'2 a10'1  a10'2 a11'1  a11'2 a12'1  a12'2 a13'1  a13'2 a14' a15' a16' a17' a18'1  a18'2 a19'1  a19'2 a20'1  a20'2 a21'1  a21'2 a22'1  a22'2 a23' a24' a25' a26' >>= \res ->
  552   peekEnergyBasisSwap res >>= \res' ->
  553   errorCheck  a26'>>
  554   return (res')
  555 
  556 
  557 
  558 qlCreatePricingPeriods_ :: (Day) -> (Day) -> (CommodityType) -> (UnitOfMeasure) -> (Double) -> (DeliverySchedule) -> (QuantityPeriodicity) -> (PaymentTerm) -> IO (([Day]), ([Day]), ([Day]), ([CommodityType]), ([UnitOfMeasure]), ([Double]))
  559 qlCreatePricingPeriods_ a1 a2 a3 a4 a5 a6 a7 a8 =
  560   withDay a1 $ \a1' -> 
  561   withDay a2 $ \a2' -> 
  562   withCommodityType a3 $ \a3' -> 
  563   withUnitOfMeasure a4 $ \a4' -> 
  564   let {a5' = realToFrac a5} in 
  565   let {a6' = fromEnumC a6} in 
  566   let {a7' = fromEnumC a7} in 
  567   withPaymentTerm a8 $ \a8' -> 
  568   preIntArray $ \(a9'1, a9'2) -> 
  569   preIntArray $ \(a10'1, a10'2) -> 
  570   preIntArray $ \(a11'1, a11'2) -> 
  571   preCommodityTypeArray $ \(a12'1, a12'2) -> 
  572   preUnitOfMeasureArray $ \(a13'1, a13'2) -> 
  573   preDoubleArray $ \(a14'1, a14'2) -> 
  574   preErrorCheck $ \a15' -> 
  575   qlCreatePricingPeriods_'_ a1' a2' a3' a4' a5' a6' a7' a8' a9'1  a9'2 a10'1  a10'2 a11'1  a11'2 a12'1  a12'2 a13'1  a13'2 a14'1  a14'2 a15' >>
  576   peekDayArray  a9'1  a9'2>>= \a9'' -> 
  577   peekDayArray  a10'1  a10'2>>= \a10'' -> 
  578   peekDayArray  a11'1  a11'2>>= \a11'' -> 
  579   peekCommodityTypeArray  a12'1  a12'2>>= \a12'' -> 
  580   peekUnitOfMeasureArray  a13'1  a13'2>>= \a13'' -> 
  581   peekDoubleArray  a14'1  a14'2>>= \a14'' -> 
  582   errorCheck  a15'>>
  583   return (a9'', a10'', a11'', a12'', a13'', a14'')
  584 
  585 
  586 
  587 -- |Split @[startDate, endDate)@ into 'PricingPeriod's of the given quantity, per a
  588 -- 'DeliverySchedule'\/'QuantityPeriodicity'\/'PaymentTerm' combination --
  589 -- @CommodityPricingHelper::createPricingPeriods@. Upstream only actually implements two
  590 -- combinations ('Monthly' with 'PerMonth', 'Daily' with 'PerDay'); every other 'DeliverySchedule'
  591 -- silently returns @[]@ (no periods, no error -- checked directly against
  592 -- @commoditypricinghelpers.cpp@, not assumed from the header).
  593 createPricingPeriods :: Day -> Day -> Quantity -> DeliverySchedule -> QuantityPeriodicity -> PaymentTerm -> IO PricingPeriods
  594 createPricingPeriods startDate endDate (ct, uom, amt) deliverySchedule qtyPeriodicity pmtTerm = do
  595   (starts, ends, pays, types, uoms, amts) <-
  596     qlCreatePricingPeriods_ startDate endDate ct uom amt deliverySchedule qtyPeriodicity pmtTerm
  597   pure $ zipWith6 (\s e p t u a -> pricingPeriod s e p (t, u, a)) starts ends pays types uoms amts
  598 
  599 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
  600 
  601 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlCommodityCashFlowDiscountedAmount"
  602   discountedAmount'_ :: ((C2HSImp.Ptr (CCommodityCashFlow')) -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCurrency))) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
  603 
  604 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlCommodityCashFlowUndiscountedAmount"
  605   undiscountedAmount'_ :: ((C2HSImp.Ptr (CCommodityCashFlow')) -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCurrency))) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
  606 
  607 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlCommodityCashFlowDiscountedPaymentAmount"
  608   discountedPaymentAmount'_ :: ((C2HSImp.Ptr (CCommodityCashFlow')) -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCurrency))) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
  609 
  610 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlCommodityCashFlowUndiscountedPaymentAmount"
  611   undiscountedPaymentAmount'_ :: ((C2HSImp.Ptr (CCommodityCashFlow')) -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCurrency))) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
  612 
  613 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlCommodityCashFlowDiscountFactor"
  614   discountFactor'_ :: ((C2HSImp.Ptr (CCommodityCashFlow')) -> (IO C2HSImp.CDouble))
  615 
  616 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlCommodityCashFlowPaymentDiscountFactor"
  617   paymentDiscountFactor'_ :: ((C2HSImp.Ptr (CCommodityCashFlow')) -> (IO C2HSImp.CDouble))
  618 
  619 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlCommodityCashFlowFinalized"
  620   finalized'_ :: ((C2HSImp.Ptr (CCommodityCashFlow')) -> (IO C2HSImp.CInt))
  621 
  622 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlCommodityAddPricingError"
  623   addPricingError'_ :: ((C2HSImp.Ptr (CCommodity')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO ())))))
  624 
  625 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlCommoditySecondaryCostAmounts"
  626   qlCommoditySecondaryCostAmounts_'_ :: ((C2HSImp.Ptr (CCommodity')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar))) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr (CCurrency)))) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))))
  627 
  628 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlCommodityPricingErrors"
  629   qlCommodityPricingErrors_'_ :: ((C2HSImp.Ptr (CCommodity')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar))) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar))) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))))
  630 
  631 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlEnergyCommodityQuantity"
  632   qlEnergyCommodityQuantity_'_ :: ((C2HSImp.Ptr (CEnergyCommodity')) -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCommodityType))) -> ((C2HSImp.Ptr (C2HSImp.Ptr (CUnitOfMeasure))) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble)))))
  633 
  634 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlEnergyFuture"
  635   qlEnergyFuture_'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCommodityType)) -> ((C2HSImp.Ptr (CUnitOfMeasure)) -> (C2HSImp.CDouble -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CUnitOfMeasure)) -> ((C2HSImp.Ptr (CCommodityIndex')) -> ((C2HSImp.Ptr (CCommodityType)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCurrency))) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CUnitOfMeasure))) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CEnergyFuture')))))))))))))))))))))))
  636 
  637 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlEnergySwapDailyPositions"
  638   qlEnergySwapDailyPositions_'_ :: ((C2HSImp.Ptr (CEnergySwap')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))))))))))))
  639 
  640 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlEnergySwapPaymentCashFlows"
  641   paymentCashFlows'_ :: ((C2HSImp.Ptr (CEnergySwap')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr (CCommodityCashFlow')))) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
  642 
  643 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlEnergyVanillaSwap"
  644   qlEnergyVanillaSwap_'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CUnitOfMeasure)) -> ((C2HSImp.Ptr (CCommodityIndex')) -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCurrency)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCommodityType))) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CUnitOfMeasure))) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> ((C2HSImp.Ptr (CCommodityType)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCurrency))) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CUnitOfMeasure))) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CEnergyVanillaSwap'))))))))))))))))))))))))))))))))))))))
  645 
  646 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlEnergyBasisSwap"
  647   qlEnergyBasisSwap_'_ :: ((C2HSImp.Ptr (CCalendar)) -> ((C2HSImp.Ptr (CCommodityIndex')) -> ((C2HSImp.Ptr (CCommodityIndex')) -> ((C2HSImp.Ptr (CCommodityIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CCurrency)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCommodityType))) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CUnitOfMeasure))) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CUnitOfMeasure)) -> ((C2HSImp.Ptr (CCommodityType)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CCurrency))) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CUnitOfMeasure))) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (CYieldTermStructure')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CEnergyBasisSwap'))))))))))))))))))))))))))))))))))))))))
  648 
  649 foreign import ccall safe "QuantLib/Instrument/Energy.chs.h qlCreatePricingPeriods"
  650   qlCreatePricingPeriods_'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CCommodityType)) -> ((C2HSImp.Ptr (CUnitOfMeasure)) -> (C2HSImp.CDouble -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (CPaymentTerm)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr (CCommodityType)))) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr (CUnitOfMeasure)))) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))))))))))))))))))