[Haskell-cafe] The applicative instances for Either?

Daniel Fischer daniel.is.fischer at googlemail.com
Sat Sep 17 11:10:24 CEST 2011

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- (ghc-6.12.3), but it was in 
base- (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, 

-- 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

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

More information about the Haskell-Cafe mailing list