[Haskell-cafe] This code produces an infinite output... why? it's a bug in ghc?

Ryan Yates fryguybob at gmail.com
Mon Jan 19 01:01:55 UTC 2015


This has something to do with the Enum instance for NominalDiffTime:

    ghci> [0..2] :: [NominalDiffTime]
    ...

Appears to also diverge.  This works though:

    ghci> mapM_ putStrLn $ map (mkDated . fromIntegral) [0..2]
    2015-01-01T00:00:00Z
    2015-01-01T01:00:00Z
    2015-01-01T02:00:00Z


Ryan



On Sun, Jan 18, 2015 at 7:45 PM, mariopal <mariopal at gmail.com> wrote:

> This code produces an infinite output... why? it's a bug in ghc?
>
> > -- Glasgow Haskell Compiler, Version 7.6.3 on Debian Sid
> > import System.Locale (defaultTimeLocale)
> > import Data.Time
> >
> >
> > mkDated n = formatTime defaultTimeLocale "%FT%TZ" $ addUTCTime (3600*n) $
> UTCTime (fromGregorian 2015 1 1) (timeOfDayToTime $ TimeOfDay 0 0 0)
> >
> > main = mapM_ putStrLn $ map mkDated [0..2]
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20150118/ac36aec0/attachment.html>


More information about the Haskell-Cafe mailing list