pa-ba / compdata

Haskell library implementing "Data Types a la Carte"
http://hackage.haskell.org/package/compdata
Other
89 stars 27 forks source link

Use `MonadFail` constraint when we need to `fail` #33

Closed pniedzielski closed 3 years ago

pniedzielski commented 4 years ago

This PR fixes issue #29, and related issues that arose, but were not described by that issue. This will also unblock issue #32, which is a result of the failing compilation on recent GHCs.

Background

The acceptance of the MonadFail proposal resulted in a breaking change in GHC 8.8.1 and onward, with an earlier migration period in older versions of base, in which Monad's fail function is moved to a new class, MonadFail. In earlier GHCs, Monad maintains its fail function for backwards compatibility, and MonadFail is defined in a separate module Control.Monad.Fail. With GHC 8.8.1, the fail function is removed from Monad, and MonadFail is exported from Prelude. What this means for us is that compdata and its benchmarks and examples fail to compile on these newer GHCs.

There have been two PRs to fix this issue already:

Neither of these PRs fix the complete problem though, as they only change the Data.Comp.Thunk module, not the same issues that crop up in the benchmarks and the examples.

This PR

The changes in this PR fix all the compilation errors and warnings related to the MonadFail proposal in 8.x-series GHCs by selectively importing the Control.Monad.Fail module, depending on the version of base, and adding MonadFail constraints where necessary. To make sure our changes compile properly, we add newer GHCs to our travisci test matrix.

We also bump the required version of base to the one that started the MonadFail migration. We think this is licensed, because we are already using MonadFail in parts of the code (which presumably caused a failure in compilation on GHC 7.x), and because commit fe05efb explicitly removes earlier GHCs from the test matrix. If we want to support earlier versions of GHC, we can introduce a dependency on the fail package.

Testing

This PR compiles without warnings on all tested 8.x-series GHCs: https://travis-ci.com/github/pniedzielski/compdata/builds/193484821

pniedzielski commented 3 years ago

Hi @pa-ba, I'd just like to follow up on this. Having compdata fail to compile on recent GHCs is a blocker for me, and it seems several other people.

pniedzielski commented 3 years ago

Hi @pa-ba, I'm just checking in on this. Having a compiling compdata on Hackage is the only blocking issue from uploading my own package there.

pa-ba commented 3 years ago

Hi @pniedzielski, many thanks for the PR! Sorry about the long wait. I'll push the update to Hackage shortly.

pniedzielski commented 3 years ago

Thanks, @pa-ba !