dhall-lang / dhall-to-cabal

Compile Dhall expressions to Cabal files
MIT License
100 stars 19 forks source link

Cabal complains about "unexpected Unknown SPDX license identifier" #176

Open sjakobi opened 5 years ago

sjakobi commented 5 years ago

Given

let GitHub-project =
      https://raw.githubusercontent.com/ocharles/dhall-to-cabal/1.3.4.0/dhall/utils/GitHub-project.dhall

let types =
      https://raw.githubusercontent.com/ocharles/dhall-to-cabal/1.3.4.0/dhall/types.dhall

let prelude =
      https://raw.githubusercontent.com/ocharles/dhall-to-cabal/1.3.4.0/dhall/prelude.dhall

in    GitHub-project { owner = "sjakobi", repo = "repro" }
    ⫽ { license = types.License.BSD3, version = prelude.v "0" }

dhall-to-cabal-1.3.4.0 produces a cabal file, about which cabal complains:

$ cabal check
Warning: repro.cabal:13:14:
unexpected Unknown SPDX license identifier: 'BSD3' Do you mean BSD-3-Clause?
Errors encountered when parsing cabal file ./repro.cabal:

repro.cabal:13:14: error:
unexpected Unknown SPDX license identifier: 'BSD3' Do you mean BSD-3-Clause?

   12 | version: 0
   13 | license: BSD3
      |              ^
cabal: parse error
sjakobi commented 5 years ago

Ah, apparently the licence identifier syntax depends on the Cabal version: https://github.com/haskell/cabal/issues/5109.

ocharles commented 5 years ago

Which Cabal version do you have? I'm surprised cabal didn't reject it based on cabal-version.

sjakobi commented 5 years ago

I think I tried both with cabal-2.4 and a recentish master.

sjakobi commented 5 years ago

Ah, apparently the licence identifier syntax depends on the Cabal version: haskell/cabal#5109.

So these combinations are ok:

cabal-version: 2.0
license: BSD3
cabal-version: 2.2
license: BSD-3-Clause

This one isn't:

cabal-version: 2.2
licence: BSD3

This one does parse, but the license isn't recognized:

cabal-version: 2.0
licence: BSD-3-Clause
quasicomputational commented 5 years ago

Yeah, this is a genuine wart; #100 was prompted by the same issue.

It comes down to that we can create a GenericPackageDescription that Cabal actually considers to be somehow invalid; we can maybe do better by offering Package_v2_2 and Package_v2_0 as separate branches of a sum, the former only accepting SPDX and the latter not. I'm not sure it's worth the complexity.

sjakobi commented 5 years ago

Is compatibility with Cabal < 2.2 an important concern for this project? Maybe it would be easier to just remove the legacy licence types.