The applicative instances for Either?

Hi, I have a program that makes use of the applicative instance for Either String. I used to define these instances locally, but at some point, they became part of Control.Applicative. I have limited the dependencies to 'base >= 4', but apparently, some version 4s of base include this instance, some do not, and it causes problems for people trying to compile the program. Is there any information, or otherwise accessible source specifying exactly when this was changed, so that I can have more precise dependencies? And is there a simple way to handle this conditionally, either within cabal, or using CPP? -k -- If I haven't seen further, it is by standing in the footprints of giants

A natural reference would be the darcs repository
http://darcs.haskell.org/packages/base/
or its git mirror
http://darcs.haskell.org/packages/base.git
which I used because getting it is much faster.
Using 'git blame Control/Applicative.hs' I figured out that the instance
was added in this commit:
commit 8abb469bd2210d78da74b334a0f4397be5ac37f6
Author: Ross Paterson
Hi,
I have a program that makes use of the applicative instance for Either String. I used to define these instances locally, but at some point, they became part of Control.Applicative. I have limited the dependencies to 'base >= 4', but apparently, some version 4s of base include this instance, some do not, and it causes problems for people trying to compile the program.
Is there any information, or otherwise accessible source specifying exactly when this was changed, so that I can have more precise dependencies? And is there a simple way to handle this conditionally, either within cabal, or using CPP?
-- Roman I. Cheplyaka :: http://ro-che.info/

On Saturday 17 September 2011, 08:42:42, Ketil Malde wrote:
Hi,
I have a program that makes use of the applicative instance for Either String. I used to define these instances locally, but at some point, they became part of Control.Applicative. I have limited the dependencies to 'base >= 4', but apparently, some version 4s of base include this instance, some do not, and it causes problems for people trying to compile the program.
Is there any information, or otherwise accessible source specifying exactly when this was changed,
Commited on 18th June 2010 to HEAD ;) Checking the sources, it wasn't in base-4.2.0.2 (ghc-6.12.3), but it was in base-4.3.1.0 (ghc-7.0.2), so it was introduced with base-4.3
so that I can have more precise dependencies? And is there a simple way to handle this conditionally, either within cabal, or using CPP?
Simplest way would be CPP, I think. Cabal provides a MIN_VERSION_foo macro, so -- The extra parentheses might be necessary, some Cabal version(s) -- had a buggy MIN_VERSION macro, I don't remember the details #if !(MIN_VERSION_base(4,3,0)) instance Applicative (Either e) where ... #endif You can have a flag based on which the version of the module with or without the instance is imported, but the above seems much simpler

Daniel Fischer
Is there any information, or otherwise accessible source specifying exactly when this was changed,
Checking the sources, it wasn't in base-4.2.0.2 (ghc-6.12.3), but it was in base-4.3.1.0 (ghc-7.0.2), so it was introduced with base-4.3
Thanks to you, and everybody else who replied. Now, it turns out, both me (who get this instance from imports) and my user (who doesn't) are using base-4.2.0.2, so it has to be elsewhere. The duplicate instance reports Control.Monad.Trans.Error - hackage insists this is part of "transformers", which I don't use, but maybe mtl imports and reexports the instances? Apparently this is the case, I tried to ghc-pkg hide mtl-2, and then I could load a file declaring an instance for Error e => Applicative (Either e) using mtl-1. So it appears I should require mtl >= 2 (and possibly base >= 4.3 as an alternative, but I guess mtl-2 is not too draconian). (This case was a bit opaque for me, I'm not sure how it could be made easier to trace down conflicts like this, perhaps I just don't know the right tools.) -k -- If I haven't seen further, it is by standing in the footprints of giants

Ketil Malde writes:
I have a program that makes use of the applicative instance for Either String. I used to define these instances locally, but at some point, they became part of Control.Applicative. I have limited the dependencies to 'base >= 4', but apparently, some version 4s of base include this instance, some do not, and it causes problems for people trying to compile the program.
Is there any information, or otherwise accessible source specifying exactly when this was changed, so that I can have more precise dependencies?
base is released with GHC, so the info is in the release notes for a major GHC release (library interfaces aren't allowed to change in minor releases): http://www.haskell.org/ghc/docs/7.0.1/html/users_guide/release-7-0-1.html#id... 1.5.10.2. base * Version number 4.3.0.0 (was 4.2.0.2) [...] * There are now Applicative, Monad and MonadFix instances for Either.
participants (4)
-
Daniel Fischer
-
Ketil Malde
-
Paterson, Ross
-
Roman Cheplyaka