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