I've been trying to install BNF converter from cabal, however there is a problem building it. Apparently, this package uses a mix of modules from haskell98 and version 4.* of base. This presents a problem in that if you compile with haskell98 hidden then some modules are not found. However, if you compile with haskell98 exposed then ghc cannot tell if it's supposed to use the new Prelude or the haskell98 Prelude!
The error message:
Main.hs:1:1:
Ambiguous module name `Prelude':
it was found in multiple packages: base haskell98-2.0.0.1
How do you resolve errors like this?
Pester the maintainers to upload a fix. Or, if they are unresponsive, consider taking over maintenance yourself.
This is because haskell98 is a compatibility package that duplicates functions in other modules. New code shouldn't depend on it, unless it's meant to be Haskell-98 compatible. However this change is relatively recent, and a lot of older code references both "base" and "haskell98" although it doesn't actually use the "haskell98" package.
In the immediate term, I would run cabal unpack BNFC
, then edit the ".cabal" file and remove the reference to haskell98
from the "build-depends:" field. I would also bump the version number for a library (this step doesn't matter for executables). Then build and install from the local copy you just edited. There may be other issues if BNFC was meant to use mtl version 1, but you can add that constraint yourself if necessary.
A workaround would be using the language extensions NoImplicitPrelude
and PackageImports
. The former prevents Haskell from importing one of the Preludes, which would fail. The second extension allows to specify the package and the version from which to import a module:
import "base" Prelude
or
import "haskell98" Prelude
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With