ghc type mismatch due to different package versions
Summary
We stumbled upon the following:
• Couldn't match type ‘bytestring-0.10.8.2:Data.ByteString.Internal.ByteString’
with ‘ByteString’
NB: ‘ByteString’
is defined in ‘Data.ByteString.Internal.Type’
in package ‘bytestring-0.11.4.0’
‘bytestring-0.10.8.2:Data.ByteString.Internal.ByteString’
is defined in ‘Data.ByteString.Internal’
in package ‘bytestring-0.10.8.2’
Expected type: Field -> Parser Day
Actual type: ByteString -> Parser Day
• In the expression: parseDate
In an equation for ‘parseField’: parseField = parseDate
In the instance declaration for ‘FromField Day’
This seems to be due to cassava
relying on bytestring
0.10, while the type in scope and related functions come from an installed bytestring
0.11.
Unfortunately, the PackageImports
syntax does not allow to specify a package version.
We could try to select the desired package by using the compiler's options, but -hide-all-packages
won't help because it prevents some locally installed packages to access their dependencies. -hide-package bytestring-0.11.4.2
, on the other hand, fails with the surprising error:
<command line>: cannot satisfy -hide-package bytestring-0.11.4.2
(use -v for more information)
Since we just want to hide a package, we would expect no errors even if the package was not visible. Anyway this is just some temporary puzzlement, as it turns out that we wrote the version wrong, so the error is arguably helpful.
Once the right version is specified, the compiler starts and mostly works, although it seems to still fail at some stage, between Renamer and Upsweep, with the same problem:
Ambiguous module name ‘Data.ByteString.Lazy’:
it was found in multiple packages:
bytestring-0.10.8.2 bytestring-0.11.4.0
The compiler version is 8.6.5. Before updating i would be interested to know whether this has been fixed in a later version. Furthermore, since this use case touched a diverse array of limitations, i thought it might be worth issuing anyway.
Here the complete error including some contextual lines:
*** Parser [Lumaposta]:
!!! Parser [Lumaposta]: finished in 2.81 milliseconds, allocated 4.923 megabytes
*** Renamer/typechecker [Lumaposta]:
!!! Renamer/typechecker [Lumaposta]: finished in 25.23 milliseconds, allocated 12.681 megabytes
lumaposta.hs:9:1: error:
Ambiguous module name ‘Data.ByteString’:
it was found in multiple packages:
bytestring-0.10.8.2 bytestring-0.11.4.0
|
9 | import Data.ByteString (ByteString)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lumaposta.hs:16:1: error:
Ambiguous module name ‘Data.ByteString’:
it was found in multiple packages:
bytestring-0.10.8.2 bytestring-0.11.4.0
|
16 | import qualified Data.ByteString as ByteString
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lumaposta.hs:17:1: error:
Ambiguous module name ‘Data.ByteString.Lazy’:
it was found in multiple packages:
bytestring-0.10.8.2 bytestring-0.11.4.0
|
17 | import qualified Data.ByteString.Lazy as Lazy
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lumaposta.hs:18:1: error:
Ambiguous module name ‘Data.ByteString.Char8’:
it was found in multiple packages:
bytestring-0.10.8.2 bytestring-0.11.4.0
|
18 | import qualified Data.ByteString.Char8 as Char8
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Upsweep partially successful.
*** Deleting temp files:
Deleting:
link(batch): upsweep (partially) failed OR
Main.main not exported; not linking.
*** Deleting temp files:
Deleting:
*** Deleting temp dirs:
Deleting:
Environment
- GHC version used: 8.6.5