[Haskell-cafe] Unexpected type error

Antoine Latter aslatter at gmail.com
Mon Jun 13 04:12:32 CEST 2011

On Sun, Jun 12, 2011 at 4:00 PM, Alexander Solla <alex.solla at gmail.com> wrote:
> Hi everybody,
> I'm having a bit of a problem with Parsec.  The most relevant error message
> is:
>  Couldn't match expected type `Text.Parsec.Prim.ParsecT
>                                     String ()
> Control.Monad.Identity.Identity String'
>            against inferred type
> `parsec-
>                                     [Char]'
>  In the expression: countMinMax ...
> So apparently, the module/package that defines countMinMax and the current
> module are using different versions of Parsec.  My global GHC database has
> Parsec 3.1.1 installed, but each package has the constraint
> parsec                         >=2.1      && <2.2
> Both modules use the exact same import line:
> import Text.ParserCombinators.Parsec -- Lime.Data.IPAddress
> import Text.ParserCombinators.Parsec -- Lime.Utility.Parsec
> countMinMax :: (Integral n) => n -> n -> Parser a -> Parser [a]
> and
> the expression GHC is complaining about above has type Parser String.
> The cabal-dev package database contains only one version of Parsec:
> parsec-
> What's going on here?

Types from differing versions of the same module are specifically not
compatible - even if they are defined identically (in this case they
are different, though).

You can do one of two things:

1. Edit the package description of the package that wants the older
version of parsec to allow to use the new one. Also, it helps to
slightly bump the version number of the package when you do this.

2. Use the older version of parsec in your software. You already have
it installed (or else the package you want to use wouldn't be able to
load!). If you're using ghci you can start it with the option
'-package parsec-'.


> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list