dhall-lang / dhall-to-cabal

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

dhall-to-cabal seems to calculate hashes differently than dhall #133

Closed mitchellwrosen closed 6 years ago

mitchellwrosen commented 6 years ago

Given a dhall file such as:

https://raw.githubusercontent.com/dhall-lang/dhall-to-cabal/1.3.0.0/dhall/types/Flag.dhall
  sha256:a7b13903200be1a2306c7c5dc1dda2f17aa9ac2d957c4be80ba8e125e4907dad

I can use dhall to evaluate it as:

$ dhall < ./flag.dhall
{ default : Bool, description : Text, manual : Bool, name : Text }

However, dhall-to-cabal seems to calculate the wrong hash:

$ dhall-to-cabal ./flag.dhall
dhall-to-cabal: 
↳ https://raw.githubusercontent.com/dhall-lang/dhall-to-cabal/1.3.0.0/dhall/types/Flag.dhall sha256:a7b13903200be1a2306c7c5dc1dda2f17aa9ac2d957c4be80ba8e125e4907dad
Error: Import integrity check failed

Expected hash:

↳ a7b13903200be1a2306c7c5dc1dda2f17aa9ac2d957c4be80ba8e125e4907dad

Actual hash:

↳ 7cc6f4de5132ac16d3792f06810c2c43ec8e63d884615b12cbdbf96ba1239c48

Am I possibly misunderstanding how this all fits together? (I know flag.dhall does not make a valid cabal file, but dhall-to-cabal doesn't get that far.)

mitchellwrosen commented 6 years ago

I'm on dhall-1.17.0, dhall-to-cabal-1.3.0.1

jneira commented 6 years ago

I think dhall-to-cabal-1.3.0.1 uses dhall-1.16.1 and there have been changes that will have affected the calculation of the hash. Could you build it from master? it already uses dhall-1.17.0

jneira commented 6 years ago

Alternatively you can compute the hash using the old protocol version of dhall with dhall hash --protocol-version 1.0 < file.dhall: it should be the same one dhall-to-cabal-1.3.0.1 uses

mitchellwrosen commented 6 years ago

That's exactly it! Thank you sir.