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.Time.Date
    6   (
    7     -- * Types
    8     Day
    9   , Month(..)
   10   , Weekday(..)
   11   , ImmMonth(..)
   12 
   13     -- * Constructors
   14     -- ** Bounds and current date
   15   , minDate
   16   , maxDate
   17   , today
   18     -- ** Months
   19   , january
   20   , february
   21   , march
   22   , april
   23   , may
   24   , june
   25   , july
   26   , august
   27   , september
   28   , october
   29   , november
   30   , december
   31 
   32     -- * Mutators
   33   , addEcbDate
   34   , removeEcbDate
   35 
   36     -- * Inspectors
   37     -- ** Date arithmetic
   38   , endOfMonth
   39   , nextWeekday
   40   , nthWeekday
   41   , addPeriod
   42     -- ** IMM dates and codes
   43   , immCode
   44   , immDate
   45   , nextImmCode
   46   , nextImmCodeFromCode
   47   , nextImmDate
   48   , nextImmDateFromCode
   49     -- ** ECB maintenance dates
   50   , ecbCode
   51   , ecbDateFromCode
   52   , ecbDate
   53   , nextEcbCodeFromCode
   54   , nextEcbCode
   55   , nextEcbDateFromCode
   56   , nextEcbDate
   57   , nextEcbDatesFromCode
   58   , nextEcbDates
   59     -- ** Date fields
   60   , isLeap
   61   , year
   62   , month
   63   , weekday
   64   , dayOfYear
   65   , isEndOfMonth
   66     -- ** IMM and ECB predicates
   67   , isImmCode
   68   , isImmDate
   69   , isEcbCode
   70   , isEcbDate
   71   , knownEcbDates
   72   ) where
   73 import qualified Foreign.C.String as C2HSImp
   74 import qualified Foreign.C.Types as C2HSImp
   75 import qualified Foreign.Marshal.Utils as C2HSImp
   76 import qualified Foreign.Ptr as C2HSImp
   77 import qualified System.IO.Unsafe as C2HSImp
   78 
   79 
   80 import Control.Exception (mask_)
   81 import Data.Time.Calendar(toGregorian, isLeapYear, fromGregorian)
   82 import Data.Time.Clock(getCurrentTime)
   83 import Data.Time.LocalTime(localDay, getTimeZone, utcToLocalTime)
   84 
   85 import QuantLib.Internal
   86 import QuantLib.Internal.Common
   87 
   88 
   89 
   90 
   91 
   92 
   93 data Month = January
   94            | Jan
   95            | February
   96            | Feb
   97            | March
   98            | Mar
   99            | April
  100            | Apr
  101            | May
  102            | June
  103            | Jun
  104            | July
  105            | Jul
  106            | August
  107            | Aug
  108            | September
  109            | Sep
  110            | October
  111            | Oct
  112            | November
  113            | Nov
  114            | December
  115            | Dec
  116   deriving (Show,Eq,Read,Bounded,Ord)
  117 instance Enum Month where
  118   succ January = February
  119   succ Jan = February
  120   succ February = March
  121   succ Feb = March
  122   succ March = April
  123   succ Mar = April
  124   succ April = May
  125   succ Apr = May
  126   succ May = June
  127   succ June = July
  128   succ Jun = July
  129   succ July = August
  130   succ Jul = August
  131   succ August = September
  132   succ Aug = September
  133   succ September = October
  134   succ Sep = October
  135   succ October = November
  136   succ Oct = November
  137   succ November = December
  138   succ Nov = December
  139   succ December = error "Month.succ: December has no successor"
  140   succ Dec = error "Month.succ: Dec has no successor"
  141 
  142   pred February = January
  143   pred Feb = January
  144   pred March = February
  145   pred Mar = February
  146   pred April = March
  147   pred Apr = March
  148   pred May = April
  149   pred June = May
  150   pred Jun = May
  151   pred July = June
  152   pred Jul = June
  153   pred August = July
  154   pred Aug = July
  155   pred September = August
  156   pred Sep = August
  157   pred October = September
  158   pred Oct = September
  159   pred November = October
  160   pred Nov = October
  161   pred December = November
  162   pred Dec = November
  163   pred January = error "Month.pred: January has no predecessor"
  164   pred Jan = error "Month.pred: Jan has no predecessor"
  165 
  166   enumFromTo from to = go from
  167     where
  168       end = fromEnum to
  169       go v = case compare (fromEnum v) end of
  170                  LT -> v : go (succ v)
  171                  EQ -> [v]
  172                  GT -> []
  173 
  174   enumFrom from = enumFromTo from Dec
  175 
  176   fromEnum January = 1
  177   fromEnum Jan = 1
  178   fromEnum February = 2
  179   fromEnum Feb = 2
  180   fromEnum March = 3
  181   fromEnum Mar = 3
  182   fromEnum April = 4
  183   fromEnum Apr = 4
  184   fromEnum May = 5
  185   fromEnum June = 6
  186   fromEnum Jun = 6
  187   fromEnum July = 7
  188   fromEnum Jul = 7
  189   fromEnum August = 8
  190   fromEnum Aug = 8
  191   fromEnum September = 9
  192   fromEnum Sep = 9
  193   fromEnum October = 10
  194   fromEnum Oct = 10
  195   fromEnum November = 11
  196   fromEnum Nov = 11
  197   fromEnum December = 12
  198   fromEnum Dec = 12
  199 
  200   toEnum 1 = January
  201   toEnum 2 = February
  202   toEnum 3 = March
  203   toEnum 4 = April
  204   toEnum 5 = May
  205   toEnum 6 = June
  206   toEnum 7 = July
  207   toEnum 8 = August
  208   toEnum 9 = September
  209   toEnum 10 = October
  210   toEnum 11 = November
  211   toEnum 12 = December
  212   toEnum unmatched = error ("Month.toEnum: Cannot match " ++ show unmatched)
  213 
  214 
  215 data Weekday = Sunday
  216              | Sun
  217              | Monday
  218              | Mon
  219              | Tuesday
  220              | Tue
  221              | Wednesday
  222              | Wed
  223              | Thursday
  224              | Thu
  225              | Friday
  226              | Fri
  227              | Saturday
  228              | Sat
  229   deriving (Show,Eq,Read,Bounded,Ord)
  230 instance Enum Weekday where
  231   succ Sunday = Monday
  232   succ Sun = Monday
  233   succ Monday = Tuesday
  234   succ Mon = Tuesday
  235   succ Tuesday = Wednesday
  236   succ Tue = Wednesday
  237   succ Wednesday = Thursday
  238   succ Wed = Thursday
  239   succ Thursday = Friday
  240   succ Thu = Friday
  241   succ Friday = Saturday
  242   succ Fri = Saturday
  243   succ Saturday = error "Weekday.succ: Saturday has no successor"
  244   succ Sat = error "Weekday.succ: Sat has no successor"
  245 
  246   pred Monday = Sunday
  247   pred Mon = Sunday
  248   pred Tuesday = Monday
  249   pred Tue = Monday
  250   pred Wednesday = Tuesday
  251   pred Wed = Tuesday
  252   pred Thursday = Wednesday
  253   pred Thu = Wednesday
  254   pred Friday = Thursday
  255   pred Fri = Thursday
  256   pred Saturday = Friday
  257   pred Sat = Friday
  258   pred Sunday = error "Weekday.pred: Sunday has no predecessor"
  259   pred Sun = error "Weekday.pred: Sun has no predecessor"
  260 
  261   enumFromTo from to = go from
  262     where
  263       end = fromEnum to
  264       go v = case compare (fromEnum v) end of
  265                  LT -> v : go (succ v)
  266                  EQ -> [v]
  267                  GT -> []
  268 
  269   enumFrom from = enumFromTo from Sat
  270 
  271   fromEnum Sunday = 1
  272   fromEnum Sun = 1
  273   fromEnum Monday = 2
  274   fromEnum Mon = 2
  275   fromEnum Tuesday = 3
  276   fromEnum Tue = 3
  277   fromEnum Wednesday = 4
  278   fromEnum Wed = 4
  279   fromEnum Thursday = 5
  280   fromEnum Thu = 5
  281   fromEnum Friday = 6
  282   fromEnum Fri = 6
  283   fromEnum Saturday = 7
  284   fromEnum Sat = 7
  285 
  286   toEnum 1 = Sunday
  287   toEnum 2 = Monday
  288   toEnum 3 = Tuesday
  289   toEnum 4 = Wednesday
  290   toEnum 5 = Thursday
  291   toEnum 6 = Friday
  292   toEnum 7 = Saturday
  293   toEnum unmatched = error ("Weekday.toEnum: Cannot match " ++ show unmatched)
  294 
  295 
  296 data ImmMonth = F
  297               | G
  298               | H
  299               | J
  300               | K
  301               | M
  302               | N
  303               | Q
  304               | U
  305               | V
  306               | X
  307               | Z
  308   deriving (Show,Eq,Read,Bounded,Ord)
  309 instance Enum ImmMonth where
  310   succ F = G
  311   succ G = H
  312   succ H = J
  313   succ J = K
  314   succ K = M
  315   succ M = N
  316   succ N = Q
  317   succ Q = U
  318   succ U = V
  319   succ V = X
  320   succ X = Z
  321   succ Z = error "ImmMonth.succ: Z has no successor"
  322 
  323   pred G = F
  324   pred H = G
  325   pred J = H
  326   pred K = J
  327   pred M = K
  328   pred N = M
  329   pred Q = N
  330   pred U = Q
  331   pred V = U
  332   pred X = V
  333   pred Z = X
  334   pred F = error "ImmMonth.pred: F has no predecessor"
  335 
  336   enumFromTo from to = go from
  337     where
  338       end = fromEnum to
  339       go v = case compare (fromEnum v) end of
  340                  LT -> v : go (succ v)
  341                  EQ -> [v]
  342                  GT -> []
  343 
  344   enumFrom from = enumFromTo from Z
  345 
  346   fromEnum F = 1
  347   fromEnum G = 2
  348   fromEnum H = 3
  349   fromEnum J = 4
  350   fromEnum K = 5
  351   fromEnum M = 6
  352   fromEnum N = 7
  353   fromEnum Q = 8
  354   fromEnum U = 9
  355   fromEnum V = 10
  356   fromEnum X = 11
  357   fromEnum Z = 12
  358 
  359   toEnum 1 = F
  360   toEnum 2 = G
  361   toEnum 3 = H
  362   toEnum 4 = J
  363   toEnum 5 = K
  364   toEnum 6 = M
  365   toEnum 7 = N
  366   toEnum 8 = Q
  367   toEnum 9 = U
  368   toEnum 10 = V
  369   toEnum 11 = X
  370   toEnum 12 = Z
  371   toEnum unmatched = error ("ImmMonth.toEnum: Cannot match " ++ show unmatched)
  372 
  373 
  374 
  375 year :: Day -> Int
  376 year x = fromIntegral y where (y, _, _) = toGregorian x
  377 
  378 -- |returns TRUE if the given date's year is leap
  379 isLeap :: Day -> Bool
  380 isLeap = isLeapYear . fromIntegral . year
  381 
  382 month :: Day -> Month
  383 month x = let (_, m, _) = toGregorian x in toEnum m
  384 
  385 -- |helper function that is convenient for use as an infix operator
  386 january :: Int -> Int -> Day
  387 january d y = fromGregorian (fromIntegral y) 1 d
  388 february :: Int -> Int -> Day
  389 february d y = fromGregorian (fromIntegral y) 2 d
  390 march :: Int -> Int -> Day
  391 march d y = fromGregorian (fromIntegral y) 3 d
  392 april :: Int -> Int -> Day
  393 april d y = fromGregorian (fromIntegral y) 4 d
  394 may :: Int -> Int -> Day
  395 may d y = fromGregorian (fromIntegral y) 5 d
  396 june :: Int -> Int -> Day
  397 june d y = fromGregorian (fromIntegral y) 6 d
  398 july :: Int -> Int -> Day
  399 july d y = fromGregorian (fromIntegral y) 7 d
  400 august :: Int -> Int -> Day
  401 august d y = fromGregorian (fromIntegral y) 8 d
  402 september :: Int -> Int -> Day
  403 september d y = fromGregorian (fromIntegral y) 9 d
  404 october :: Int -> Int -> Day
  405 october d y = fromGregorian (fromIntegral y) 10 d
  406 november :: Int -> Int -> Day
  407 november d y = fromGregorian (fromIntegral y) 11 d
  408 december :: Int -> Int -> Day
  409 december d y = fromGregorian (fromIntegral y) 12 d
  410 
  411 -- |the day of the week for the given date
  412 weekday :: (Day) -> IO ((Weekday))
  413 weekday a1 =
  414   withDay a1 $ \a1' -> 
  415   weekday'_ a1' >>= \res ->
  416   let {res' = (toEnum . fromIntegral) res} in
  417   return (res')
  418 
  419 
  420 
  421 today :: IO Day
  422 today = do
  423   now <- getCurrentTime
  424   tz <- getTimeZone now
  425   return $ localDay $ utcToLocalTime tz now
  426 
  427 -- |One-based (Jan 1st = 1)
  428 dayOfYear :: (Day) -> IO ((Int))
  429 dayOfYear a1 =
  430   withDay a1 $ \a1' -> 
  431   dayOfYear'_ a1' >>= \res ->
  432   let {res' = fromIntegral res} in
  433   return (res')
  434 
  435 
  436 
  437 -- |last day of the month to which the given date belongs
  438 endOfMonth :: (Day) -> IO ((Day))
  439 endOfMonth a1 =
  440   withDay a1 $ \a1' -> 
  441   endOfMonth'_ a1' >>= \res ->
  442   let {res' = toDay res} in
  443   return (res')
  444 
  445 
  446 
  447 -- |whether a date is the last day of its month
  448 isEndOfMonth :: (Day) -> IO ((Bool))
  449 isEndOfMonth a1 =
  450   withDay a1 $ \a1' -> 
  451   isEndOfMonth'_ a1' >>= \res ->
  452   let {res' = C2HSImp.toBool res} in
  453   return (res')
  454 
  455 
  456 
  457 -- |next given weekday following or equal to the given date
  458 -- E.g., the Friday following Tuesday, January 15th, 2002 was January 18th, 2002.see http://www.cpearson.com/excel/DateTimeWS.htm
  459 nextWeekday :: (Day) -> (Weekday) -> IO ((Day))
  460 nextWeekday a1 a2 =
  461   withDay a1 $ \a1' -> 
  462   let {a2' = (fromIntegral . fromEnum) a2} in 
  463   nextWeekday'_ a1' a2' >>= \res ->
  464   let {res' = toDay res} in
  465   return (res')
  466 
  467 
  468 
  469 -- |n-th given weekday in the given month and year
  470 -- E.g., the 4th Thursday of March, 1998 was March 26th, 1998.see http://www.cpearson.com/excel/DateTimeWS.htm
  471 -- /Warning/ It raises an exception unless the n-th falls in 1..5
  472 nthWeekday :: (Word) -> (Weekday) -> (Month) -> (Int) -> IO ((Day))
  473 nthWeekday a1 a2 a3 a4 =
  474   let {a1' = fromIntegral a1} in 
  475   let {a2' = (fromIntegral . fromEnum) a2} in 
  476   let {a3' = (fromIntegral . fromEnum) a3} in 
  477   let {a4' = fromIntegral a4} in 
  478   preErrorCheck $ \a5' -> 
  479   nthWeekday'_ a1' a2' a3' a4' a5' >>= \res ->
  480   let {res' = toDay res} in
  481   errorCheck  a5'>>
  482   return (res')
  483 
  484 
  485 
  486 -- |returns the IMM code for the given date (e.g. H3 for March 20th, 2013). /Warning/ It raises an exception if the input date is not an IMM date
  487 immCode :: (Day) -> IO ((String))
  488 immCode a1 =
  489   withDay a1 $ \a1' -> 
  490   preErrorCheck $ \a2' -> 
  491   immCode'_ a1' a2' >>= \res ->
  492   peekDynString res >>= \res' ->
  493   errorCheck  a2'>>
  494   return (res')
  495 
  496 
  497 
  498 -- |returns the IMM date for the given IMM code (e.g. March 20th, 2013 for H3). /Warning/ It raises an exception if the input string is not an IMM code
  499 immDate :: (String) -> (Day) -> IO ((Day))
  500 immDate a1 a2 =
  501   C2HSImp.withCString a1 $ \a1' -> 
  502   withDay a2 $ \a2' -> 
  503   preErrorCheck $ \a3' -> 
  504   immDate'_ a1' a2' a3' >>= \res ->
  505   let {res' = toDay res} in
  506   errorCheck  a3'>>
  507   return (res')
  508 
  509 
  510 
  511 -- |returns whether or not the given string is an IMM code
  512 isImmCode :: (String) -- ^immCode
  513  -> (Bool) -- ^mainCycle
  514  -> (Bool)
  515 isImmCode a1 a2 =
  516   C2HSImp.unsafePerformIO $
  517   C2HSImp.withCString a1 $ \a1' -> 
  518   let {a2' = C2HSImp.fromBool a2} in 
  519   isImmCode'_ a1' a2' >>= \res ->
  520   let {res' = C2HSImp.toBool res} in
  521   return (res')
  522 
  523 
  524 
  525 -- |returns whether or not the given date is an IMM date
  526 isImmDate :: (Day) -> (Bool) -- ^mainCycle
  527  -> IO ((Bool))
  528 isImmDate a1 a2 =
  529   withDay a1 $ \a1' -> 
  530   let {a2' = C2HSImp.fromBool a2} in 
  531   isImmDate'_ a1' a2' >>= \res ->
  532   let {res' = C2HSImp.toBool res} in
  533   return (res')
  534 
  535 
  536 
  537 -- |next IMM code following the given code
  538 -- returns the IMM code for next contract listed in the International Money Market section of the Chicago Mercantile Exchange.
  539 nextImmCodeFromCode :: (String) -> (Bool) -- ^mainCycle
  540  -> (Day) -> IO ((String))
  541 nextImmCodeFromCode a1 a2 a3 =
  542   C2HSImp.withCString a1 $ \a1' -> 
  543   let {a2' = C2HSImp.fromBool a2} in 
  544   withDay a3 $ \a3' -> 
  545   preErrorCheck $ \a4' -> 
  546   nextImmCodeFromCode'_ a1' a2' a3' a4' >>= \res ->
  547   peekDynString res >>= \res' ->
  548   errorCheck  a4'>>
  549   return (res')
  550 
  551 
  552 
  553 -- |next IMM code following the given date
  554 -- returns the IMM code for next contract listed in the International Money Market section of the Chicago Mercantile Exchange.
  555 nextImmCode :: Day -> Bool -> IO String
  556 nextImmCode x y = mask_ (nextImmCodeRaw x y)
  557 nextImmCodeRaw :: (Day) -> (Bool) -- ^mainCycle
  558  -> IO ((String))
  559 nextImmCodeRaw a1 a2 =
  560   withDay a1 $ \a1' -> 
  561   let {a2' = C2HSImp.fromBool a2} in 
  562   nextImmCodeRaw'_ a1' a2' >>= \res ->
  563   peekDynString res >>= \res' ->
  564   return (res')
  565 
  566 
  567 
  568 -- |next IMM date following the given IMM code
  569 -- returns the 1st delivery date for next contract listed in the International Money Market section of the Chicago Mercantile Exchange.
  570 nextImmDateFromCode :: (String) -> (Bool) -- ^mainCycle
  571  -> (Day) -- ^referenceDate
  572  -> IO ((Day))
  573 nextImmDateFromCode a1 a2 a3 =
  574   C2HSImp.withCString a1 $ \a1' -> 
  575   let {a2' = C2HSImp.fromBool a2} in 
  576   withDay a3 $ \a3' -> 
  577   preErrorCheck $ \a4' -> 
  578   nextImmDateFromCode'_ a1' a2' a3' a4' >>= \res ->
  579   let {res' = toDay res} in
  580   errorCheck  a4'>>
  581   return (res')
  582 
  583 
  584 
  585 -- |next IMM date following the given date
  586 -- returns the 1st delivery date for next contract listed in the International Money Market section of the Chicago Mercantile Exchange.
  587 nextImmDate :: (Day) -> (Bool) -- ^mainCycle
  588  -> IO ((Day))
  589 nextImmDate a1 a2 =
  590   withDay a1 $ \a1' -> 
  591   let {a2' = C2HSImp.fromBool a2} in 
  592   nextImmDate'_ a1' a2' >>= \res ->
  593   let {res' = toDay res} in
  594   return (res')
  595 
  596 
  597 
  598 -- |the given date advanced by a period
  599 addPeriod :: (Day) -> (Int,TimeUnit) -> IO ((Day))
  600 addPeriod a1 a2 =
  601   withDay a1 $ \a1' -> 
  602   let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  603   preErrorCheck $ \a3' -> 
  604   addPeriod'_ a1' a2'1  a2'2 a3' >>= \res ->
  605   let {res' = toDay res} in
  606   errorCheck  a3'>>
  607   return (res')
  608 
  609 
  610 
  611 -- |adds a date to the set of known ECB maintenance period start dates
  612 addEcbDate :: (Day) -> IO ()
  613 addEcbDate a1 =
  614   withDay a1 $ \a1' -> 
  615   preErrorCheck $ \a2' -> 
  616   addEcbDate'_ a1' a2' >>
  617   errorCheck  a2'>>
  618   return ()
  619 
  620 
  621 
  622 -- |returns the ECB code for the given date (e.g. MAR10 for March xxth, 2010).Warning It raises an exception if the input date is not an ECB date
  623 ecbCode :: (Day) -> IO ((String))
  624 ecbCode a1 =
  625   withDay a1 $ \a1' -> 
  626   preErrorCheck $ \a2' -> 
  627   ecbCode'_ a1' a2' >>= \res ->
  628   peekDynString res >>= \res' ->
  629   errorCheck  a2'>>
  630   return (res')
  631 
  632 
  633 
  634 -- |returns the ECB date for the given ECB code (e.g. March xxth, 2013 for MAR10).WarningIt raises an exception if the input string is not an ECB code
  635 ecbDateFromCode :: (String) -> (Maybe Day) -> IO ((Day))
  636 ecbDateFromCode a1 a2 =
  637   C2HSImp.withCString a1 $ \a1' -> 
  638   withMaybeDay a2 $ \a2' -> 
  639   preErrorCheck $ \a3' -> 
  640   ecbDateFromCode'_ a1' a2' a3' >>= \res ->
  641   let {res' = toDay res} in
  642   errorCheck  a3'>>
  643   return (res')
  644 
  645 
  646 
  647 -- |maintenance period start date in the given month/year
  648 ecbDate :: (Month) -> (Int) -> IO ((Day))
  649 ecbDate a1 a2 =
  650   let {a1' = (fromIntegral . fromEnum) a1} in 
  651   let {a2' = fromIntegral a2} in 
  652   preErrorCheck $ \a3' -> 
  653   ecbDate'_ a1' a2' a3' >>= \res ->
  654   let {res' = toDay res} in
  655   errorCheck  a3'>>
  656   return (res')
  657 
  658 
  659 
  660 -- |returns whether or not the given string is an ECB code
  661 isEcbCode :: (String) -> IO ((Bool))
  662 isEcbCode a1 =
  663   C2HSImp.withCString a1 $ \a1' -> 
  664   preErrorCheck $ \a2' -> 
  665   isEcbCode'_ a1' a2' >>= \res ->
  666   let {res' = C2HSImp.toBool res} in
  667   errorCheck  a2'>>
  668   return (res')
  669 
  670 
  671 
  672 -- |returns whether or not the given date is a maintenance period start date
  673 isEcbDate :: (Day) -> IO ((Bool))
  674 isEcbDate a1 =
  675   withDay a1 $ \a1' -> 
  676   preErrorCheck $ \a2' -> 
  677   isEcbDate'_ a1' a2' >>= \res ->
  678   let {res' = C2HSImp.toBool res} in
  679   errorCheck  a2'>>
  680   return (res')
  681 
  682 
  683 
  684 -- |the set of known ECB maintenance period start dates
  685 knownEcbDates :: IO (([Day]))
  686 knownEcbDates =
  687   preIntArray $ \(a1'1, a1'2) -> 
  688   preErrorCheck $ \a2' -> 
  689   knownEcbDates'_ a1'1  a1'2 a2' >>
  690   peekDayArray  a1'1  a1'2>>= \a1'' -> 
  691   errorCheck  a2'>>
  692   return (a1'')
  693 
  694 
  695 
  696 -- |next ECB code following the given code
  697 nextEcbCodeFromCode :: (String) -> IO ((String))
  698 nextEcbCodeFromCode a1 =
  699   C2HSImp.withCString a1 $ \a1' -> 
  700   preErrorCheck $ \a2' -> 
  701   nextEcbCodeFromCode'_ a1' a2' >>= \res ->
  702   C2HSImp.peekCString res >>= \res' ->
  703   errorCheck  a2'>>
  704   return (res')
  705 
  706 
  707 
  708 -- |next ECB code following the given date
  709 nextEcbCode :: (Maybe Day) -> IO ((String))
  710 nextEcbCode a1 =
  711   withMaybeDay a1 $ \a1' -> 
  712   preErrorCheck $ \a2' -> 
  713   nextEcbCode'_ a1' a2' >>= \res ->
  714   C2HSImp.peekCString res >>= \res' ->
  715   errorCheck  a2'>>
  716   return (res')
  717 
  718 
  719 
  720 -- |next maintenance period start date following the given ECB code
  721 nextEcbDateFromCode :: (String) -> (Maybe Day) -> IO ((Day))
  722 nextEcbDateFromCode a1 a2 =
  723   C2HSImp.withCString a1 $ \a1' -> 
  724   withMaybeDay a2 $ \a2' -> 
  725   preErrorCheck $ \a3' -> 
  726   nextEcbDateFromCode'_ a1' a2' a3' >>= \res ->
  727   let {res' = toDay res} in
  728   errorCheck  a3'>>
  729   return (res')
  730 
  731 
  732 
  733 -- |next maintenance period start date following the given date
  734 nextEcbDate :: (Maybe Day) -> IO ((Day))
  735 nextEcbDate a1 =
  736   withMaybeDay a1 $ \a1' -> 
  737   preErrorCheck $ \a2' -> 
  738   nextEcbDate'_ a1' a2' >>= \res ->
  739   let {res' = toDay res} in
  740   errorCheck  a2'>>
  741   return (res')
  742 
  743 
  744 
  745 -- |next maintenance period start dates following the given code
  746 nextEcbDatesFromCode :: (String) -> (Maybe Day) -> IO (([Day]))
  747 nextEcbDatesFromCode a1 a2 =
  748   C2HSImp.withCString a1 $ \a1' -> 
  749   withMaybeDay a2 $ \a2' -> 
  750   preIntArray $ \(a3'1, a3'2) -> 
  751   preErrorCheck $ \a4' -> 
  752   nextEcbDatesFromCode'_ a1' a2' a3'1  a3'2 a4' >>
  753   peekDayArray  a3'1  a3'2>>= \a3'' -> 
  754   errorCheck  a4'>>
  755   return (a3'')
  756 
  757 
  758 
  759 -- |next maintenance period start dates following the given date
  760 nextEcbDates :: (Maybe Day) -> IO (([Day]))
  761 nextEcbDates a1 =
  762   withMaybeDay a1 $ \a1' -> 
  763   preIntArray $ \(a2'1, a2'2) -> 
  764   preErrorCheck $ \a3' -> 
  765   nextEcbDates'_ a1' a2'1  a2'2 a3' >>
  766   peekDayArray  a2'1  a2'2>>= \a2'' -> 
  767   errorCheck  a3'>>
  768   return (a2'')
  769 
  770 
  771 
  772 -- |removes a date from the set of known ECB maintenance period start dates
  773 removeEcbDate :: (Day) -> IO ()
  774 removeEcbDate a1 =
  775   withDay a1 $ \a1' -> 
  776   preErrorCheck $ \a2' -> 
  777   removeEcbDate'_ a1' a2' >>
  778   errorCheck  a2'>>
  779   return ()
  780 
  781 
  782 
  783 -- vim: set ff=unix ts=8 sts=2 sw=2 et:
  784 
  785 foreign import ccall safe "QuantLib/Time/Date.chs.h qlWeekday"
  786   weekday'_ :: (C2HSImp.CInt -> (IO C2HSImp.CInt))
  787 
  788 foreign import ccall safe "QuantLib/Time/Date.chs.h qlDateDayOfYear"
  789   dayOfYear'_ :: (C2HSImp.CInt -> (IO C2HSImp.CInt))
  790 
  791 foreign import ccall safe "QuantLib/Time/Date.chs.h qlDateEndOfMonth"
  792   endOfMonth'_ :: (C2HSImp.CInt -> (IO C2HSImp.CInt))
  793 
  794 foreign import ccall safe "QuantLib/Time/Date.chs.h qlDateIsEndOfMonth"
  795   isEndOfMonth'_ :: (C2HSImp.CInt -> (IO C2HSImp.CInt))
  796 
  797 foreign import ccall safe "QuantLib/Time/Date.chs.h qlDateNextWeekday"
  798   nextWeekday'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))
  799 
  800 foreign import ccall safe "QuantLib/Time/Date.chs.h qlDateNthWeekday"
  801   nthWeekday'_ :: (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt))))))
  802 
  803 foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMCode"
  804   immCode'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr C2HSImp.CChar))))
  805 
  806 foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMDate"
  807   immDate'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt))))
  808 
  809 foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMIsIMMcode"
  810   isImmCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))
  811 
  812 foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMIsIMMdate"
  813   isImmDate'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))
  814 
  815 foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMNextCode1"
  816   nextImmCodeFromCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr C2HSImp.CChar))))))
  817 
  818 foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMNextCode"
  819   nextImmCodeRaw'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (IO (C2HSImp.Ptr C2HSImp.CChar))))
  820 
  821 foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMNextDate1"
  822   nextImmDateFromCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))))
  823 
  824 foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMNextDate"
  825   nextImmDate'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))
  826 
  827 foreign import ccall safe "QuantLib/Time/Date.chs.h qlAddPeriod"
  828   addPeriod'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))))
  829 
  830 foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBAddDate"
  831   addEcbDate'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))
  832 
  833 foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBCode"
  834   ecbCode'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr C2HSImp.CChar))))
  835 
  836 foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBDate1"
  837   ecbDateFromCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt))))
  838 
  839 foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBDate"
  840   ecbDate'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt))))
  841 
  842 foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBIsECBcode"
  843   isEcbCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))
  844 
  845 foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBIsECBdate"
  846   isEcbDate'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))
  847 
  848 foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBKnownDates"
  849   knownEcbDates'_ :: ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))
  850 
  851 foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBNextCode1"
  852   nextEcbCodeFromCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr C2HSImp.CChar))))
  853 
  854 foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBNextCode"
  855   nextEcbCode'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO (C2HSImp.Ptr C2HSImp.CChar))))
  856 
  857 foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBNextDate1"
  858   nextEcbDateFromCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt))))
  859 
  860 foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBNextDate"
  861   nextEcbDate'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO C2HSImp.CInt)))
  862 
  863 foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBNextDates1"
  864   nextEcbDatesFromCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ()))))))
  865 
  866 foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBNextDates"
  867   nextEcbDates'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))))
  868 
  869 foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBRemoveDate"
  870   removeEcbDate'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (IO ())))