
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