tailcalled
tailcalled

Reputation: 85

Building contravariant using Stack leads to constraint error about not being able to deduce Contravariant

When building my project, I get errors like the following:

   /tmp/stack19408/contravariant-1.5/src/Data/Functor/Contravariant/Divisible.hs:233:10: error:
        • Could not deduce (Contravariant (Backwards f))
            arising from the superclasses of an instance declaration
          from the context: Divisible f
            bound by the instance declaration
            at src/Data/Functor/Contravariant/Divisible.hs:233:10-47
        • In the instance declaration for ‘Divisible (Backwards f)’
        |
    233 | instance Divisible f => Divisible (Backwards f) where
        |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I can't figure out exactly what is going on here, or whether the mistake is on my end or a problem with the libraries involved. Did I do something wrong?


I've tried to create the smallest project possible that leads to this problem. In a blank Stack project, change the resolver to ghc-8.6.2 and add the dependencies:

extra-deps:
- contravariant-1.5
- StateVar-1.1.1.1
- base-4.12.0.0
- array-0.5.2.0

Add contravariant to dependencies in package.yaml, and import Data.Functor.Contravariant.Divisible in Lib.hs. This led to compile errors when running stack build.

Upvotes: 0

Views: 60

Answers (1)

bergey
bergey

Reputation: 3071

It's not you - released packages are not yet caught up for base-4.12.

Now that the Contravariant class is in base, the instance for Backwards should move to transformers, where the latter is defined. There's a patch that adds the instances but I don't think it's been released to Hackage.

In your shoes, I would:

  1. checkout the darcs repo locally
  2. add the local checkout as an extra-dep
  3. bug the maintainers to release transformers

Upvotes: 1

Related Questions