GithubHelp home page GithubHelp logo

chronos's People

Contributors

alaendle avatar aljce avatar andrewthad avatar avieth avatar belka-ew avatar boarders avatar brianjosephmckeon avatar chessai avatar chshersh avatar dependabot[bot] avatar galenhuntington avatar gbwey avatar goolord avatar gromakovsky avatar jacobstanley avatar jhrcek avatar kanwren avatar kleidukos avatar lucazulian avatar nobrakal avatar parsonsmatt avatar solomon-b avatar spacekitteh avatar tek avatar theghostjw avatar vrom911 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chronos's Issues

Add benchmarks for the time formatting

I see that there're benchmarks for time parsing. And I would really appreciate benchmarks for pretty-printing as well! I assume that some functions can be used for this.

Currently I have non-default time formatter using time library but it's known that time library is not the fastest one:

    showTime :: UTCTime -> Text
    showTime t = toText $
          formatTime defaultTimeLocale "%H:%M:%S." t
       ++ take 3 (formatTime defaultTimeLocale "%q" t)
       ++ formatTime defaultTimeLocale " %e %b %Y %Z" t

I would really appreciate to see benchmarks of different libraries!

P.S. You probably can add Hacktoberfest label to this issue so some people can implement it. I think that such benchmarks are extremely useful for the Haskell ecosystem.

Fails to build on Win10, incompatible integer types

Hi,
I stumbled upon this compilation failure:

src\Chronos\Internal\CTimespec.hs:53:30: error:
    * Couldn't match expected type `Int64' with actual type `Int32'
    * In the second argument of `(+)', namely `ns'
      In the first argument of `return', namely `((s * 1000000000) + ns)'
      In a stmt of a 'do' block: return ((s * 1000000000) + ns)
   |
53 |   return ((s * 1000000000) + ns)
   |                              ^^

Steps to reproduce: take a win10 machine (version 1703), then

$ stack unpack chronos && cd chronos
$ stack init

this inits to lts-14.0 (ghc-8.6.5); after that

$ stack build

and the compilation failure quickly follows.

How do I circumvent this issue? I can provide more info about my machine if needed.

Cheers!

export more useful functions from Chronos, and other suggestions

Many of the following functions I think are generally useful, while others are potentially useful to users, but none are exported.

monthLength,
isLeapYear,
ordinalDateToDay,
monthDateToDayOfYear,
dayOfYearToMonthAndDay,
dayToOrdinalDate,
parseSecondsAndNanoseconds,
countZeroes,
nanosecondsBuilder, 
microsecondsBuilder,
millisecondsBuilder,
prettyNanosecondsBuilder,
parseSecondsAndNanosecondsUtf8,
countZeroesUtf8,
nanosecondsBuilderUtf8,
microsecondsBuilderUtf8,
millisecondsBuilderUtf8,
prettyNanosecondsBuilderUtf8,
int64Builder, -- Does this even need to be defined here?
-- ** Not sure about offset stuff, but it seems like it could be useful
offsetBuilder, 
offsetParser,
parseSignedness,
parseOffset_z,
parseOffset_z1,
parseOffset_z2,
parseOffset_z3,
buildOffset_z,
buildOffset_z1,
buildOffset_z2,
buildOffset_z3,
parseSignednessUtf8,
parseOffsetUtf8_z,
parseOffsetUtf8_z1,
parseOffsetUtf8_z2,
parseOffsetUtf8_z3,
buildOffsetUtf8_z,
buildOffsetUtf8_z1,
buildOffsetUtf8_z2,
buildOffsetUtf8_z3,
-- ** End of offset stuff
--
-- ** Not sure about this stuff
countDigits,
clip,
parseFixedDigits,
parseFixedDigitsIntBS,
indexTwoDigitTextBuilder,
indexTwoDigitByteStringBuilder,
twoDigitByteStringBuilder,
twoDigitTextBuilder,
monthToZeroPaddedDigit,
zeroPadDayOfMonth,
monthToZeroPaddedDigitBS,
zeroPadDayOfMonthBS

Additionally, the following are a list of all official UTC Offsets, as integers:

100,200,300,330,400,430,500,530,545,600,630,700,800,845,900,930,1000,1030,1100,1200,1245,1300,1345,1400,0,-100,-200,-230,-300,-330,-400,-500,-600,-700,-800,-900,-930,-1000,-1100,-1200

Lastly, I think it would be useful to provide Enum and Bounded instances for things that do not currently have them (e.g. Offset), however, this could prove to be less user friendly by taking away some flexibility that users have.

EDIT: Also providing Torsor instances for things such as Offset.

TimeInterval datatype?

i think the following would be useful:

data TimeInterval = TimeInterval {-# UNPACK #-} !Time {-# UNPACK #-} !Time

because now it's easy for users to talk about times within a range, without relying on Timespan. IME the concept of Timespan, where one has to fix a Timespan to a time in order to use it, is typically confusing.

For example we could write a function within which looks like:

within :: Time -> TimeInterval -> Bool
t `within` (TimeInterval t0 t1) = t >= t0 && t <= t1

Compile failures with GHC 7.8

I've noticed that all releases of chronos declare support for base >= 4.7, however GHC disagrees:

Configuring component lib from chronos-0.3
Preprocessing library chronos-0.3...
[ 1 of 22] Compiling Chronos.Internal.CTimespec ( src/Chronos/Internal/CTimespec.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/Internal/CTimespec.o )
[ 2 of 22] Compiling Chronos.Internal ( src/Chronos/Internal.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/Internal.o )
[ 3 of 22] Compiling Chronos.Types    ( src/Chronos/Types.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/Types.o )
[ 4 of 22] Compiling Chronos.Calendar ( src/Chronos/Calendar.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/Calendar.o )
[ 5 of 22] Compiling Chronos.Match    ( src/Chronos/Match.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/Match.o )
[ 6 of 22] Compiling Chronos.Nanoseconds ( src/Chronos/Nanoseconds.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/Nanoseconds.o )
[ 7 of 22] Compiling Chronos.Internal.Conversion ( src/Chronos/Internal/Conversion.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/Internal/Conversion.o )
[ 8 of 22] Compiling Chronos.Posix    ( src/Chronos/Posix.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/Posix.o )
[ 9 of 22] Compiling Chronos.Day      ( src/Chronos/Day.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/Day.o )
[10 of 22] Compiling Chronos.Internal.Format ( src/Chronos/Internal/Format.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/Internal/Format.o )
[11 of 22] Compiling Chronos.Date.Text ( src/Chronos/Date/Text.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/Date/Text.o )
[12 of 22] Compiling Chronos.Date.ByteString.Char7 ( src/Chronos/Date/ByteString/Char7.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/Date/ByteString/Char7.o )
[13 of 22] Compiling Chronos.Datetime ( src/Chronos/Datetime.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/Datetime.o )
[14 of 22] Compiling Chronos.TimeOfDay.Text ( src/Chronos/TimeOfDay/Text.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/TimeOfDay/Text.o )
[15 of 22] Compiling Chronos.Datetime.Text ( src/Chronos/Datetime/Text.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/Datetime/Text.o )
[16 of 22] Compiling Chronos.TimeOfDay.ByteString.Char7 ( src/Chronos/TimeOfDay/ByteString/Char7.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/TimeOfDay/ByteString/Char7.o )
[17 of 22] Compiling Chronos.Datetime.ByteString.Char7 ( src/Chronos/Datetime/ByteString/Char7.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/Datetime/ByteString/Char7.o )
[18 of 22] Compiling Chronos.OffsetDatetime.Text ( src/Chronos/OffsetDatetime/Text.hs, /tmp/matrix-worker/1480432575/dist-newstyle/build/x86_64-linux/ghc-7.8.4/chronos-0.3/build/Chronos/OffsetDatetime/Text.o )

src/Chronos/OffsetDatetime/Text.hs:40:3:
    Not in scope: ‘<$>’
    Perhaps you meant one of these:
      ‘Atto.<?>’ (imported from Data.Attoparsec.Text),
      ‘<>’ (imported from Data.Monoid)

src/Chronos/OffsetDatetime/Text.hs:41:3:
    Not in scope: ‘<*>’
    Perhaps you meant one of these:
      ‘Atto.<?>’ (imported from Data.Attoparsec.Text),
      ‘Atto.<*.’ (imported from Data.Attoparsec.Text),
      ‘Atto..*>’ (imported from Data.Attoparsec.Text)

You can correct the meta-data for existing releases on Hackage yourself via

or I can do it for you.

While at it, the description ("Please see README.md") is not a proper description for your package (and Hackage will show a link to the README at the end of the description if the README is contained in the source tarball (however, it is not); therefore that phrase is redundant), and hence this will cause poor experience for users (NB: your package won't be properly indexed by Hackage's package search feature and thus hurt its discoverability). See also this posting for more details.

If you have any questions, please let me know!

Build fails on 32 bit POSIX systems

This looks like the same issue as #35, but #36 only fixes it for Windows.

src/Chronos/Internal/CTimespec.hs:60:3: error:
    • Couldn't match type ‘Int32’ with ‘Int64’
      Expected type: IO Int64
        Actual type: IO Int32
    • In a stmt of a 'do' block: return ((s * 1000000000) + ns)
      In the expression:
        do CTimespec (CTime s) (CLong ns) <- alloca $ \ ptspec -> do ...
           return ((s * 1000000000) + ns)
      In an equation for ‘getPosixNanoseconds’:
          getPosixNanoseconds
            = do CTimespec (CTime s) (CLong ns) <- alloca $ \ ptspec -> ...
                 return ((s * 1000000000) + ns)
   |
60 |   return ((s * 1000000000) + ns)
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Specifically I am seeing this on armv7a-unknown-linux-androideabi.

API for week-of-year?

I can't find an API to obtain week-of-year from a Datetime, is it intended so or missing by accident?

Builders don't zero-pad years

encoding a date with Year 1 results in 1-01-01, which cannot be read by the parsers, since they use parseFixedDigits 4.
Is the date string 0001-01-01 invalid according to some standard or is this an oversight?

fails to compile on mac

Hi! I'm using version 1.0.3, compilation fails at the C step:

[4 of 4] Compiling Chronos.Locale.English ( src/Chronos/Locale/English.hs, dist/build/Chronos/Locale/English.o )
clang: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument]

src/cbits/hs-time.c:4:5: error:
     error: conflicting types for 'clock_gettime'
  |
4 | int clock_gettime(int clk_id, struct timespec* t) {
  |     ^
int clock_gettime(int clk_id, struct timespec* t) {
    ^

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/time.h:177:5: error:
     note: previous declaration is here
    |
177 | int clock_gettime(clockid_t __clock_id, struct timespec *__tp);
    |     ^
int clock_gettime(clockid_t __clock_id, struct timespec *__tp);
    ^
1 error generated.
`clang' failed in phase `C Compiler'. (Exit code: 1)

Let me know if I can give you more information!

Please publish the most recent dep. version bumps to hackage

Hello @andrewthad
could you please release new version of chronos to hackage?
It would be great to have a version on hackage which supports all the latest versions of text, semigroups and aeson (which is what you have on master but is not yet available on hackage). This is the only thing that I'm missing from being able to switch my project to ghc 9.2.4 (without depending on specific package revision on github)

Enum instance for Date

Following my discovery that base provides an Enum instance for Integer, I'm more keen on adding an Enum instance for Date, even though fromEnum and toEnum don't really have good definitions.

Converting a Time (or DateTime) to seconds

Hi, @andrewthad, I'm using cryptographic APIs that need sometimes a timestamp in seconds. Reading the API reference of Chronos it's not obvious which function I should use to convert a time or datetime object to an integer that expresses the time in seconds (instead of nanoseconds).

Is this a situation where the Torsor package is useful?

Compatibility layer/conversion interface for standard time types

Hi,

given there are significant number of third-party libraries that use time for their calendar-related interfaces, that don't plan to switch to chronos any time soon, what is the recommened way to integrate those libraries with chronos-based APIs? thyme for instance has lenses and compatibility layer that makes it easy to interface with the existing codebases that rely on time type definitions. Is there something similar for chrnos? Thank you.

Consider using `intervals` instead of baked in interval type

There's a nice package here that just adds intervals to an arbitrary ordered type (and provides a wealth of operations with respect to them). E.g. here's some fiddling with the time package and intervals to implement something someone was asking about in slack:

module Main where

import Data.Time
import Numeric.Interval
import Numeric.Interval as I
import Data.Functor.Compose

type Event a t = (Maybe a, Interval t)

findEvents :: Ord t => Interval t -> [Event a t] -> [Event a t]
findEvents i =
  filter (not . I.null . snd)
  . getCompose
  . fmap (intersection i)
  . Compose

calendar :: [Event String Day]
calendar =
  [ (Just "event1", read "2019-01-01" ... read "2019-01-05")
  , (Just "event2", read "2019-01-03" ... read "2019-02-12")
  , (Just "event3", read "2019-03-01" ... read "2019-03-05")
  ]

test = read "2019-01-02" ... read "2019-01-05"

main :: IO ()
main = print $ findEvents test calendar
-- [ (Just "event1",2019-01-02 ... 2019-01-05)
-- , (Just "event2",2019-01-03 ... 2019-01-05)
-- ]

Does it make sense to just use this package instead of having a built in TimeInterval?

measure time it takes to run an action

I rewritten this same bit of logic in several different projects:

stopwatch :: IO a -> IO (Timespan, a)

It needs to use the clock package. The standard system clock is not sufficient for these kinds of measurements. I'm alright with depending on clock since it's well-written (and really lightweight). It currently doesn't work with GHCJS, but for now, that's not a huge deal.

Add builder with `MonthMatch`

It would be helpful to have a builder with which you could use MonthMatch.
For example, in co-log we needed to have months in 3-letter format (like Dec, Jan, etc.), so we implemented a builder manually:
co-log/co-log#166

If you think that it makes sense to have in the chronos library, I could help with the implementation as soon as we agree on the API (to have an additional field in the DatetimeFormat or to explicitly take a Maybe (MonthMatch a) as an argument, or something else?).

Let me know what do you think.

Oh, by the way, while implementing the builder, I have noticed that functions like zeroPadDayOfMonth etc. are not exported. Would you consider exporting them, or there is a reason not to do that? (if this question if offtopic for this issue I totally understand and could create a new one if you think that this idea makes sense at all).

lenient decode functions

It would be kind of nice to have a decode function that tried to parse a datetime several different ways. One that could accept any of the following:

2017-01-05T23:13:05
2017-01-05 23:13:05
2017/01/05 23:13:05
etc.

Add Datetime formatter that shows month in english

Currently I can use builder_DmyHMS to see the time like this:

05-05-2019 11:27:43.252

It would be nice to be able to format month in English (3 letters is enough), so I can see:

05 May 2019 11:27:43.252 +00:00

No way to obtain DayOfWeek

I've look through the API and it seems like there is no way to obtain the day of week. Did I miss something?

month is off by one on windows version

Hi,
Just to let you know, in case you have Windows users.

encode_YmdHMS SubsecondPrecisionAuto w3c . timeToDatetime <$> now
"2020-06-08T13:19:06.529"

getCurrentTime
2020-05-08 13:19:14.125906 UTC

`doctest` suite failing for me on GHC 8.10.3

I'm trying to figure out why chronos doesn't build in Nixpkgs. So I cloned the repository and the ran the commands from appveyor.yml

$ cabal build all --enable-tests --write-ghc-environment-files=always
$ cabal test all --enable-test

but this gives me the following rather long list of errors

errors
Test suite doctest: RUNNING...
ld: warning: /nix/store/hxcwxf1bhx8dhlyzjyzcgpw91b66cnrw-libiconv-osx-10.12.6/lib/libiconv.dylib, ignoring unexpected dylib file
src/Chronos.hs:404: failure in expression `\(d :: Datetime) -> timeToDatetime (datetimeToTime d) == d'

<interactive>:359:18: error:
    Not in scope: data constructor ‘Datetime’

<interactive>:359:36: error:
    Not in scope: type constructor or class ‘Datetime’

<interactive>:360:3: error:
    Variable not in scope:
      polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ

<interactive>:360:19: error:
    Variable not in scope: mkName :: t1 -> t0

src/Chronos.hs:437: failure in expression `\(d :: Day) -> dateToDay (dayToDate d) == d'

<interactive>:486:18: error: Not in scope: data constructor ‘Day’

<interactive>:486:31: error:
    Not in scope: type constructor or class ‘Day’

<interactive>:487:3: error:
    Variable not in scope:
      polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ

<interactive>:487:19: error:
    Variable not in scope: mkName :: t1 -> t0

src/Chronos.hs:446: failure in expression `\(d :: Date) -> dayToDate (dateToDay d) == d'

<interactive>:613:18: error: Not in scope: data constructor ‘Date’

<interactive>:613:32: error:
    Not in scope: type constructor or class ‘Date’

<interactive>:614:3: error:
    Variable not in scope:
      polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ

<interactive>:614:19: error:
    Variable not in scope: mkName :: t1 -> t0

src/Chronos.hs:453: failure in expression `datetimeFromYmdhms 2014 2 26 17 58 52'
expected: Datetime {datetimeDate = Date {dateYear = Year {getYear = 2014}, dateMonth = Month {getMonth = 1}, dateDay = DayOfMonth {getDayOfMonth = 26}}, datetimeTime = TimeOfDay {timeOfDayHour = 17, timeOfDayMinute = 58, timeOfDayNanoseconds = 52000000000}}
 but got: 
          ^
          <interactive>:673:1: error:
              Variable not in scope:
                datetimeFromYmdhms :: t0 -> t1 -> t2 -> t3 -> t4 -> t5 -> t

src/Chronos.hs:481: failure in expression `timeFromYmdhms 2014 2 26 17 58 52'
expected: Time {getTime = 1393437532000000000}
 but got: 
          ^
          <interactive>:732:1: error:
              Variable not in scope:
                timeFromYmdhms :: t0 -> t1 -> t2 -> t3 -> t4 -> t5 -> t

src/Chronos.hs:760: failure in expression `isLeapYear (Year 1996)'
expected: True
 but got: 
          ^
          <interactive>:791:1: error:
              Variable not in scope: isLeapYear :: t0 -> t
          
          <interactive>:791:13: error:
              Data constructor not in scope: Year :: t1 -> t0

src/Chronos.hs:808: failure in expression `encode_YmdHMS SubsecondPrecisionAuto w3c (timeToDatetime (timeFromYmdhms 2014 2 26 17 58 52))'
expected: "2014-02-26T17:58:52"
 but got: 
          ^
          <interactive>:850:1: error:
              Variable not in scope: encode_YmdHMS :: t0 -> t1 -> t2 -> t
          
          <interactive>:850:15: error:
              Data constructor not in scope: SubsecondPrecisionAuto
          
          <interactive>:850:38: error: Variable not in scope: w3c
          
          <interactive>:850:43: error:
              Variable not in scope: timeToDatetime :: t3 -> t2
          
          <interactive>:850:59: error:
              Variable not in scope:
                timeFromYmdhms :: t4 -> t5 -> t6 -> t7 -> t8 -> t9 -> t3

src/Chronos.hs:811: failure in expression `\(s :: SubsecondPrecision) (dt :: Datetime) -> isJust (decode_YmdHMS w3c (encode_YmdHMS s w3c dt))'

<interactive>:919:18: error:
    Not in scope: data constructor ‘SubsecondPrecision’

<interactive>:919:37: error:
    Not in scope: data constructor ‘Datetime’

<interactive>:919:55: error:
    Not in scope: type constructor or class ‘SubsecondPrecision’

<interactive>:919:82: error:
    Not in scope: type constructor or class ‘Datetime’

<interactive>:920:3: error:
    Variable not in scope:
      polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ

<interactive>:920:19: error:
    Variable not in scope: mkName :: t1 -> t0

src/Chronos.hs:818: failure in expression `encode_YmdHMS SubsecondPrecisionAuto slash (timeToDatetime (timeFromYmdhms 2014 2 26 17 58 52))'
expected: "2014/02/26 17:58:52"
 but got: 
          ^
          <interactive>:979:1: error:
              Variable not in scope: encode_YmdHMS :: t0 -> t1 -> t2 -> t
          
          <interactive>:979:15: error:
              Data constructor not in scope: SubsecondPrecisionAuto
          
          <interactive>:979:38: error: Variable not in scope: slash
          
          <interactive>:979:45: error:
              Variable not in scope: timeToDatetime :: t3 -> t2
          
          <interactive>:979:61: error:
              Variable not in scope:
                timeFromYmdhms :: t4 -> t5 -> t6 -> t7 -> t8 -> t9 -> t3

src/Chronos.hs:821: failure in expression `\(s :: SubsecondPrecision) (dt :: Datetime) -> isJust (decode_YmdHMS slash (encode_YmdHMS s slash dt))'

<interactive>:1048:18: error:
    Not in scope: data constructor ‘SubsecondPrecision’

<interactive>:1048:37: error:
    Not in scope: data constructor ‘Datetime’

<interactive>:1048:55: error:
    Not in scope: type constructor or class ‘SubsecondPrecision’

<interactive>:1048:82: error:
    Not in scope: type constructor or class ‘Datetime’

<interactive>:1049:3: error:
    Variable not in scope:
      polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ

<interactive>:1049:19: error:
    Variable not in scope: mkName :: t1 -> t0

src/Chronos.hs:828: failure in expression `encode_YmdHMS SubsecondPrecisionAuto hyphen (timeToDatetime (timeFromYmdhms 2014 2 26 17 58 52))'
expected: "2014-02-26 17:58:52"
 but got: 
          ^
          <interactive>:1108:1: error:
              Variable not in scope: encode_YmdHMS :: t0 -> t1 -> t2 -> t
          
          <interactive>:1108:15: error:
              Data constructor not in scope: SubsecondPrecisionAuto
          
          <interactive>:1108:38: error: Variable not in scope: hyphen
          
          <interactive>:1108:46: error:
              Variable not in scope: timeToDatetime :: t3 -> t2
          
          <interactive>:1108:62: error:
              Variable not in scope:
                timeFromYmdhms :: t4 -> t5 -> t6 -> t7 -> t8 -> t9 -> t3

src/Chronos.hs:831: failure in expression `\(s :: SubsecondPrecision) (dt :: Datetime) -> isJust (decode_YmdHMS hyphen (encode_YmdHMS s hyphen dt))'

<interactive>:1177:18: error:
    Not in scope: data constructor ‘SubsecondPrecision’

<interactive>:1177:37: error:
    Not in scope: data constructor ‘Datetime’

<interactive>:1177:55: error:
    Not in scope: type constructor or class ‘SubsecondPrecision’

<interactive>:1177:82: error:
    Not in scope: type constructor or class ‘Datetime’

<interactive>:1178:3: error:
    Variable not in scope:
      polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ

<interactive>:1178:19: error:
    Variable not in scope: mkName :: t1 -> t0

src/Chronos.hs:838: failure in expression `encode_YmdHMS SubsecondPrecisionAuto compact (timeToDatetime (timeFromYmdhms 2014 2 26 17 58 52))'
expected: "20140226T175852"
 but got: 
          ^
          <interactive>:1237:1: error:
              Variable not in scope: encode_YmdHMS :: t0 -> t1 -> t2 -> t
          
          <interactive>:1237:15: error:
              Data constructor not in scope: SubsecondPrecisionAuto
          
          <interactive>:1237:38: error: Variable not in scope: compact
          
          <interactive>:1237:47: error:
              Variable not in scope: timeToDatetime :: t3 -> t2
          
          <interactive>:1237:63: error:
              Variable not in scope:
                timeFromYmdhms :: t4 -> t5 -> t6 -> t7 -> t8 -> t9 -> t3

src/Chronos.hs:841: failure in expression `\(s :: SubsecondPrecision) (dt :: Datetime) -> isJust (decode_YmdHMS compact (encode_YmdHMS s compact dt))'

<interactive>:1306:18: error:
    Not in scope: data constructor ‘SubsecondPrecision’

<interactive>:1306:37: error:
    Not in scope: data constructor ‘Datetime’

<interactive>:1306:55: error:
    Not in scope: type constructor or class ‘SubsecondPrecision’

<interactive>:1306:82: error:
    Not in scope: type constructor or class ‘Datetime’

<interactive>:1307:3: error:
    Variable not in scope:
      polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ

<interactive>:1307:19: error:
    Variable not in scope: mkName :: t1 -> t0

src/Chronos.hs:2691: failure in expression `\(t :: Time) -> within t whole'

<interactive>:1433:18: error: Not in scope: data constructor ‘Time’

<interactive>:1433:32: error:
    Not in scope: type constructor or class ‘Time’

<interactive>:1434:3: error:
    Variable not in scope:
      polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ

<interactive>:1434:19: error:
    Variable not in scope: mkName :: t1 -> t0

Examples: 31  Tried: 30  Errors: 0  Failures: 15
Test suite doctest: FAIL
Test suite logged to: /Users/yuuki/nixstuff/chronos/dist-newstyle/build/x86_64-osx/ghc-8.10.3/chronos-1.1.2/t/doctest/test/chronos-1.1.2-doctest.log

which is also what Nixpkgs has problems with.

[nix-shell:~/nixstuff/chronos]$ cabal --version
cabal-install version 3.2.0.0
compiled using version 3.2.1.0 of the Cabal library
[nix-shell:~/nixstuff/chronos]$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.3

The issue does not happen on my NixOS machine which is using ghc 8.8.4. If I switch GHC on MacOS

$ nix-shell -p haskell.compiler.ghc884 cabal-install
$ [nix-shell:~/nixstuff/chronos]$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.8.4

it also passes on that machine.

Let me know if you need more information

Support GHC 9.2

Currently chronos doesn't build with GHC 9.2 using cabal with the following error:

Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: co-log-0.4.0.2 (user goal)
[__1] trying: chronos-1.1.3 (dependency of co-log)
[__2] trying: text-short-0.1.5 (dependency of chronos)
[__3] trying: template-haskell-2.18.0.0/installed-2.18.0.0 (dependency of
text-short)
[__4] trying: primitive-0.7.3.0 (dependency of chronos)
[__5] next goal: aeson (dependency of chronos)
[__5] rejecting: aeson-2.0.3.0 (conflict: chronos => aeson>=1.1 && <1.6)
[__5] skipping: aeson-2.0.2.0, aeson-2.0.1.0, aeson-2.0.0.0 (has the same
characteristics that caused the previous version to fail: excluded by
constraint '>=1.1 && <1.6' from 'chronos')
[__5] rejecting: aeson-1.5.6.0, aeson-1.5.5.1 (conflict: template-haskell =>
ghc-prim==0.8.0/installed-0.8.0, aeson => ghc-prim>=0.2 && <0.8)
[__5] rejecting: aeson-1.5.5.0 (conflict: template-haskell =>
base==4.16.0.0/installed-4.16.0.0, aeson => base(>=4.7.0.0 && <5) && <0)
[__5] rejecting: aeson-1.5.4.1, aeson-1.5.4.0 (conflict: template-haskell =>
ghc-prim==0.8.0/installed-0.8.0, aeson => ghc-prim>=0.2 && <0.8)
[__5] rejecting: aeson-1.5.3.0, aeson-1.5.2.0, aeson-1.5.1.0, aeson-1.5.0.0,
aeson-1.4.7.1 (conflict: template-haskell => ghc-prim==0.8.0/installed-0.8.0,
aeson => ghc-prim>=0.2 && <0.7)
[__5] rejecting: aeson-1.4.7.0, aeson-1.4.6.0, aeson-1.4.5.0, aeson-1.4.4.0,
aeson-1.4.3.0, aeson-1.4.2.0 (conflict: template-haskell =>
ghc-prim==0.8.0/installed-0.8.0, aeson => ghc-prim>=0.2 && <0.6)
[__5] rejecting: aeson-1.4.1.0 (conflict: primitive==0.7.3.0, aeson =>
primitive>=0.6.2.0 && <0.7)
[__5] trying: aeson-1.4.0.0
[__6] next goal: th-abstraction (dependency of aeson)
[__6] rejecting: th-abstraction-0.4.3.0 (conflict: aeson =>
th-abstraction>=0.2.2 && <0.3)
[__6] skipping: th-abstraction-0.4.2.0, th-abstraction-0.4.1.0,
th-abstraction-0.4.0.0, th-abstraction-0.3.2.0, th-abstraction-0.3.1.0,
th-abstraction-0.3.0.0 (has the same characteristics that caused the previous
version to fail: excluded by constraint '>=0.2.2 && <0.3' from 'aeson')
[__6] rejecting: th-abstraction-0.2.11.0 (conflict:
template-haskell==2.18.0.0/installed-2.18.0.0, th-abstraction =>
template-haskell>=2.5 && <2.15)
[__6] skipping: th-abstraction-0.2.10.0, th-abstraction-0.2.9.0,
th-abstraction-0.2.8.0, th-abstraction-0.2.7.0, th-abstraction-0.2.6.0,
th-abstraction-0.2.5.0, th-abstraction-0.2.4.0, th-abstraction-0.2.3.0,
th-abstraction-0.2.2.0, th-abstraction-0.2.1.0, th-abstraction-0.2.0.0,
th-abstraction-0.1.3.0, th-abstraction-0.1.2.1, th-abstraction-0.1.2.0,
th-abstraction-0.1.1.0, th-abstraction-0.1.0.0 (has the same characteristics
that caused the previous version to fail: excludes 'template-haskell' version
2.18.0.0)
[__6] fail (backjumping, conflict set: aeson, template-haskell,
th-abstraction)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: aeson, chronos, template-haskell,
base, th-abstraction, primitive, co-log, text-short
Try running with --minimize-conflict-set to improve the error message.

Add to Stackage?

Would you be willing to have chronos added to Stackage? You've got a few packages in there so hopefully you'd be willing to see this added to the stable set as well. If you need help maintaining this library then we can certainly ask around for some volunteers if you want a hand.

Really appreciate the design of this library. Thanks for your thoughtful work.

lenses

It's possible to add lenses for some of these things. If someone wants to do it, I'll take a PR. For documentation reasons, do the unexported type synonym thing that Gabriel does in pipes-parse so that the haddocks end up nice.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.