Using Cabal backpack in a backwards compatible fashion
Asked Answered
S

0

6

Backpack promises to let us solve the string problem by parametrizing packages over signatures. The idea is that this will allow us to change the ecosystem in a backwards compatible way: we can simply deprecate particular instantiations without changes rippling down the dependency graph.

What I am struggling to see is how I can use Backpack in a backwards compatible way. AFAICT, a backpacked project has to use Cabal 2.0 (previous versions of Cabal won't support all the new fields in .cabal files). That would mean that I can only use backpack in projects that support GHC 8.2+.

Is there any hack around this? I'm looking for a way to use backpack such that:

  • users on GHC 8.2+ can take advantage of a fully backpacked package
  • users on older versions can still compile and use the project (but are stuck with some default instantiation of the signatures)
Septi answered 26/8, 2017 at 4:30 Comment(2)
As far as I can tell, cabal will emit a warning (not an error) when it encounters a field it doesn't recognize in the cabal file; so e.g. if impl(ghc >= 8.2) { signatures: foo } will work work on v2.0 and on older versions (at least on 1.24; I don't know if this produced an error on some other version). As far as actual Haskell source files, I think at some point you'd still need to resort to CPP - but without specific examples (and I understand that these may be hard to come by given that the exploration of this feature has just begun) it's hard to say.Pavo
This is definitely tricky to do, not least because Hackage is unconditionally rejecting packages that use Backpack features. The most likely thing to work is write two Cabal files and upload them separately. A pain? Yes. It might be possible to write an autogenerator for the compat version, but this hasn't been done yet...Marry

© 2022 - 2024 — McMap. All rights reserved.