GithubHelp home page GithubHelp logo

enum-text's People

Contributors

adinapoli avatar cdornan avatar

Watchers

 avatar

Forkers

adinapoli

enum-text's Issues

Fix TextParsable UTCTime instance to be backward compatible with older time

cc @cdornan @adamgundry

Given this program:

{-# LANGUAGE TypeApplications #-}

module TestUTC where

import Data.Time
import Text.Read

main :: IO ()
main = print @(Maybe UTCTime) $ readMaybe "2020-01-01 10:12:30"

The parsing of this UTCTime differs from time time-1.8.0.2 and time-1.9.3:

stack --resolver lts-14.10 --no-system-ghc exec runghc -- TestUTC.hs
Just 2020-01-01 10:12:30 UTC

stack --resolver lts-17.5 --no-system-ghc exec runghc -- TestUTC.hs
Nothing

I haven't investigated exactly what change in time triggered it (possibly the handling of a ZonedTime) but the current instance TextParsable UTCTime behaves differently between time versions.

As discussed with @adamgundry, possibly the easiest fix would be cribbing the parseUTC from api-tools and use it here, as it does the right thing. Compare:

{-# LANGUAGE TypeApplications #-}

module TestUTC where

import Data.Time
import qualified Data.API.Time as API
import qualified Data.Text as T
import Text.Read

main :: IO ()
main = do
  print @(Maybe UTCTime) $ readMaybe "2020-01-01 10:12:30"
  print @(Maybe UTCTime) $ API.parseUTC (T.pack "2020-01-01 10:12:30")

It yields:

stack --resolver lts-14.10 --no-system-ghc exec --package api-tools-0.9.0.0 runghc -- TestUTC.hs
Just 2020-01-01 10:12:30 UTC
Just 2020-01-01 10:12:30 UTC

stack --resolver lts-17.15 --no-system-ghc exec --package api-tools-0.9.0.0 runghc -- TestUTC.hs
Nothing
Just 2020-01-01 10:12:30 UTC

testsuite fails in Stackage Nightly

Preprocessing library for enum-text-0.5.3.0..
Building library for enum-text-0.5.3.0..                                                                                     
Preprocessing test suite 'enum-text-tests' for enum-text-0.5.3.0..
Building test suite 'enum-text-tests' for enum-text-0.5.3.0..
doctest-discover: test/doctest-config.json: openFile: does not exist (No such file or directory)
                                                                                                                             
/var/stackage/work/unpack-dir/unpacked/enum-text-0.5.3.0-ad5b97504fac04b18c6704c259c0c3d6a60c86bee0ffab92ec2d27d28a3514ce/tes
t/Doctest.hs:1:1: error:                                                                                                     
    `doctest-discover' failed in phase `Haskell pre-processor'. (Exit code: 1)
  |                                                                                                                          
1 | {-# OPTIONS_GHC -F -pgmF doctest-discover -optF test/doctest-config.json #-}
  | ^                                                                                                                        

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.