time and TimeLocale compatibility

Hello all, The `formatTime` function from time-1.4 uses the TimeLocale type from old-locale, whereas time-1.5 provides its own definition of the TimeLocale type. I want to provide `formatTime` with the argument `defaultTimeLocale`. 1.4 requires the version in old-locale whereas 1.5 requires the version it defines itself. Is it possible to use this function in a way that is compatible with both 1.4 and 1.5? If time-1.5 had merely reexported the old-locale version, and then (the future) time-1.6 replaced it completely this would have offered a smoother upgrade path, but as far as I can tell nothing like this was done. What are my options? Tom

Hi Tom, This worked for me: https://ghc.haskell.org/trac/ghc/wiki/Migration/7.10#time-1.5.0.1 Cheers, Alberto On Sunday, March 22, 2015, Tom Ellis < tom-lists-haskell-cafe-2013@jaguarpaw.co.uk> wrote:
Hello all,
The `formatTime` function from time-1.4 uses the TimeLocale type from old-locale, whereas time-1.5 provides its own definition of the TimeLocale type. I want to provide `formatTime` with the argument `defaultTimeLocale`. 1.4 requires the version in old-locale whereas 1.5 requires the version it defines itself.
Is it possible to use this function in a way that is compatible with both 1.4 and 1.5? If time-1.5 had merely reexported the old-locale version, and then (the future) time-1.6 replaced it completely this would have offered a smoother upgrade path, but as far as I can tell nothing like this was done.
What are my options?
Tom _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org javascript:; http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

Thanks Alberto. It's disappointing if CPP is the only way to handle this transation. However, if this is indeed the case it would be better to do it once and for all (i.e. abstract this process into a resuable component) rather than force every package maintainer to do it on an individual level. Thus I have created the following time14-compat package providing Data.Time.Compat that can be used from both 1.4 and 1.5: https://github.com/tomjaguarpaw/haskell-time14-compat Comments welcome. I haven't tested it particularly thoroughly, but it is rather simple. I'll stick it up on Hackage once enough eyeballs have sanity-checked it. Tom On Sun, Mar 22, 2015 at 10:31:00AM +0100, Alberto Valverde wrote:
Hi Tom,
This worked for me: https://ghc.haskell.org/trac/ghc/wiki/Migration/7.10#time-1.5.0.1
Cheers, Alberto
On Sunday, March 22, 2015, Tom Ellis < tom-lists-haskell-cafe-2013@jaguarpaw.co.uk> wrote:
Hello all,
The `formatTime` function from time-1.4 uses the TimeLocale type from old-locale, whereas time-1.5 provides its own definition of the TimeLocale type. I want to provide `formatTime` with the argument `defaultTimeLocale`. 1.4 requires the version in old-locale whereas 1.5 requires the version it defines itself.
Is it possible to use this function in a way that is compatible with both 1.4 and 1.5? If time-1.5 had merely reexported the old-locale version, and then (the future) time-1.6 replaced it completely this would have offered a smoother upgrade path, but as far as I can tell nothing like this was done.
What are my options?
Tom _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org javascript:; http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

I have been informed a package for this already exists: http://hackage.haskell.org/package/time-locale-compat-0.1.0.1 On Sun, Mar 22, 2015 at 10:32:47AM +0000, Tom Ellis wrote:
I have created the following time14-compat package providing Data.Time.Compat that can be used from both 1.4 and 1.5:
https://github.com/tomjaguarpaw/haskell-time14-compat
Comments welcome. I haven't tested it particularly thoroughly, but it is rather simple. I'll stick it up on Hackage once enough eyeballs have sanity-checked it.

Tom Ellis wrote:
It's disappointing if CPP is the only way to handle this transation.
Glad that there is a compat package (and thanks for offering to create one). I agree that it's the best way. But even without a compat package, it is not necessary to use CPP even within the same package, and in my opinion better to avoid it. You can use cabal conditionals directly without going via CPP. The trick is that put your two different imports in modules with the same name in two separate source directories, and in cabal include one hs-source-dir or the other conditionally. Regards, Yitz
participants (3)
-
Alberto Valverde
-
Tom Ellis
-
Yitzchak Gale