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.Index.Commodity
    6   (
    7     -- * Types
    8     CommodityIndex
    9 
   10     -- * Constructors
   11   , commodityIndex
   12 
   13     -- * Inspectors
   14   , forwardPrice
   15   , lastQuoteDate
   16   , isEmpty
   17   ) where
   18 import qualified Foreign.C.String as C2HSImp
   19 import qualified Foreign.C.Types as C2HSImp
   20 import qualified Foreign.ForeignPtr as C2HSImp
   21 import qualified Foreign.Marshal.Utils as C2HSImp
   22 import qualified Foreign.Ptr as C2HSImp
   23 import qualified System.IO.Unsafe as C2HSImp
   24 
   25 
   26 import QuantLib.Internal
   27 import QuantLib.Internal.Type
   28 
   29 
   30 
   31 
   32 
   33 
   34 
   35 
   36 
   37 
   38 
   39 
   40 
   41 
   42 
   43 
   44 
   45 
   46 
   47 
   48 -- |A named commodity index, whose fixings forecast from an optional forward 'CommodityCurve'
   49 -- (or fall back to a stored historical fixing when none is given -- add one via
   50 -- 'QuantLib.Index.addFixing'). Upstream's constructor also takes an
   51 -- @ExchangeContracts@\/nearby-offset pair for rolling onto nearby exchange contracts; this binds
   52 -- only the no-rolling case (a null @exchangeContracts@ and offset 0), the same scope this module's
   53 -- 'QuantLib.TermStructure.Commodity.CommodityCurve' already narrowed 'price' to.
   54 -- Commodity type, currency, unit, lot quantity, and forward curve are not exposed as inspectors
   55 -- because they only echo the constructor arguments.
   56 commodityIndex :: (String) -- ^name
   57  -> (CommodityType) -> (Currency) -> (UnitOfMeasure) -> (Calendar) -> (Double) -- ^lotQuantity
   58  -> (Maybe CommodityCurve) -- ^forwardCurve
   59  -> IO ((CommodityIndex))
   60 commodityIndex a1 a2 a3 a4 a5 a6 a7 =
   61   C2HSImp.withCString a1 $ \a1' -> 
   62   withCommodityType a2 $ \a2' -> 
   63   withCurrency a3 $ \a3' -> 
   64   withUnitOfMeasure a4 $ \a4' -> 
   65   withCalendar a5 $ \a5' -> 
   66   let {a6' = realToFrac a6} in 
   67   withMaybeCommodityCurve a7 $ \a7' -> 
   68   preErrorCheck $ \a8' -> 
   69   commodityIndex'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
   70   peekCommodityIndex res >>= \res' ->
   71   errorCheck  a8'>>
   72   return (res')
   73 
   74 
   75 
   76 -- |The forecast forward price for a date, from the forward curve.
   77 forwardPrice :: (CommodityIndex) -> (Day) -> IO ((Double))
   78 forwardPrice a1 a2 =
   79   withCommodityIndex a1 $ \a1' -> 
   80   withDay a2 $ \a2' -> 
   81   preErrorCheck $ \a3' -> 
   82   forwardPrice'_ a1' a2' a3' >>= \res ->
   83   let {res' = realToFrac res} in
   84   errorCheck  a3'>>
   85   return (res')
   86 
   87 
   88 
   89 -- |The most recent date with a stored historical fixing. Throws if none has been added yet --
   90 -- check 'isEmpty' first if that's a possibility.
   91 lastQuoteDate :: (CommodityIndex) -> IO ((Day))
   92 lastQuoteDate a1 =
   93   withCommodityIndex a1 $ \a1' -> 
   94   preErrorCheck $ \a2' -> 
   95   lastQuoteDate'_ a1' a2' >>= \res ->
   96   let {res' = toDay res} in
   97   errorCheck  a2'>>
   98   return (res')
   99 
  100 
  101 
  102 -- |Whether this index has any stored historical fixings.
  103 isEmpty :: (CommodityIndex) -> (Bool)
  104 isEmpty a1 =
  105   C2HSImp.unsafePerformIO $
  106   withCommodityIndex a1 $ \a1' -> 
  107   isEmpty'_ a1' >>= \res ->
  108   let {res' = C2HSImp.toBool res} in
  109   return (res')
  110 
  111 
  112 
  113 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
  114 
  115 foreign import ccall safe "QuantLib/Index/Commodity.chs.h qlCommodityIndex"
  116   commodityIndex'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr (CCommodityType)) -> ((C2HSImp.Ptr (CCurrency)) -> ((C2HSImp.Ptr (CUnitOfMeasure)) -> ((C2HSImp.Ptr (CCalendar)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr (CCommodityCurve')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr (CCommodityIndex')))))))))))
  117 
  118 foreign import ccall safe "QuantLib/Index/Commodity.chs.h qlCommodityIndexForwardPrice"
  119   forwardPrice'_ :: ((C2HSImp.Ptr (CCommodityIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CDouble))))
  120 
  121 foreign import ccall safe "QuantLib/Index/Commodity.chs.h qlCommodityIndexLastQuoteDate"
  122   lastQuoteDate'_ :: ((C2HSImp.Ptr (CCommodityIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))
  123 
  124 foreign import ccall safe "QuantLib/Index/Commodity.chs.h qlCommodityIndexEmpty"
  125   isEmpty'_ :: ((C2HSImp.Ptr (CCommodityIndex')) -> (IO C2HSImp.CInt))