Future imports in GHC/Base

Hello all, I was wondering if there is any particular reason for Haskell/GHC not having a kind of "import from Future", similar to Python import __future__, or, in a different take, stuff like modernizr for javascript. Was this done already? My quite simple use case: I could really use the Foldable instance for Either, and also ended up defining my own 'isLeft' and 'isRight'. Felt guilty of re-inventing the wheel after seeing it defined elsewhere, it was so obvious, of course. Then I see it defined in GHC Head - but unfortunatelly not all packages support it yet. And I can only guess that installing base 4.7 on top of GHC 7.6.3 would certainly result in Cabal Hell. I ended up copying the parts that I needed. Any one else doing this? My proposal is simple, and quite restricted: 1) Include only stuff with no dependencies on new compiler features 2) Focus mainly on additional typeclasses instances 3) Or new functions, that otherwise should not interfere with existing code. 4) Use CPP to translate the code into NOP when the new compiler finally enters the Haskell Platform. Thus, a very simple "FutureGHC" package (I'm open to alternative names) would, for isLeft/isRight, be like the code proposed below - taken from GHC Head libraries, of course. What do you think? Joao {-# LANGUAGE CPP #-} -- (...) module Data.Either.GHC707 ( module Data.Either #if __GLASGOW_HASKELL__ < 707 , isLeft , isRight #endif ) where #if __GLASGOW_HASKELL__ < 707 import Data.Either -- | Return `True` if the given value is a `Left`-value, `False` otherwise. -- -- /Since: 4.7.0.0/ isLeft :: Either a b -> Bool isLeft (Left _) = True isLeft (Right _) = False -- | Return `True` if the given value is a `Right`-value, `False` otherwise. -- -- /Since: 4.7.0.0/ isRight :: Either a b -> Bool isRight (Left _) = False isRight (Right _) = True #endif

On Mon, Jan 13, 2014 at 6:47 AM, João Cristóvão
Then I see it defined in GHC Head - but unfortunatelly not all packages support it yet. And I can only guess that installing base 4.7 on top of GHC 7.6.3 would certainly result in Cabal Hell.
It's not even possible, since base includes the runtime. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Brandon, yes, it makes sense.
So, I've uploaded this into github. Its really small and simple, as
expected, but it may be useful to anybody else.
https://github.com/jcristovao/BaseFuture
Feedback welcomed,
Cheers
João
2014/1/13 Brandon Allbery
On Mon, Jan 13, 2014 at 6:47 AM, João Cristóvão
wrote: Then I see it defined in GHC Head - but unfortunatelly not all packages support it yet. And I can only guess that installing base 4.7 on top of GHC 7.6.3 would certainly result in Cabal Hell.
It's not even possible, since base includes the runtime.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Hi, On 2014-01-13 at 12:47:58 +0100, João Cristóvão wrote:
I was wondering if there is any particular reason for Haskell/GHC not having a kind of "import from Future", similar to Python import __future__, or, in a different take, stuff like modernizr for javascript.
Was this done already?
Have you seen http://hackage.haskell.org/package/base-compat ? Cheers, hvr

Hi Herbert,
I don't know how I could have missed it!
Thanks, I will send a push request to merge this.
2014/1/14 Herbert Valerio Riedel
Hi,
On 2014-01-13 at 12:47:58 +0100, João Cristóvão wrote:
I was wondering if there is any particular reason for Haskell/GHC not having a kind of "import from Future", similar to Python import __future__, or, in a different take, stuff like modernizr for javascript.
Was this done already?
Have you seen
http://hackage.haskell.org/package/base-compat
?
Cheers, hvr
participants (3)
-
Brandon Allbery
-
Herbert Valerio Riedel
-
João Cristóvão