dhall-lang / dhall-to-cabal

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

Error using cached version of prelude and types (using master version of dhall) #124

Closed jneira closed 6 years ago

jneira commented 6 years ago

Hi, i've setup a fork to use the near next versión of dhall, 1.17 with cached imports with hashes (fork diff) It includes a test case using a local import hashed and after caching the prelude and types it fails:

C:\dhall-to-etlas\golden-tests\dhall-to-cabal>dir C:\Users\user\AppData\Local\dhall /B

C:\dhall-to-etlas\golden-tests\dhall-to-cabal>dhall-to-cabal < dhall-to-cabal-http.dhall
cabal-version: 2.2
<rest of correct cabal output>

C:\dhall-to-etlas\golden-tests\dhall-to-cabal>dir C:\Users\user\AppData\Local\dhall /B
39919f424375b417e118f94da599d69bbff58b63d418fa7a1bf914005c780f06
f3ffaa13c8f2e82121145d4602ee38861b7bacbc3427649e1e6a844e448a7159

C:\dhall-to-etlas\golden-tests\dhall-to-cabal>dhall-to-cabal < dhall-to-cabal-http.dhall
dhall-to-cabal: App (Var (V "_" 0)) (TextLit (Chunks [] "1.0.0"))
CallStack (from HasCallStack):
  error, called at lib\DhallToCabal.hs:245:11 in dhall-to-cabal-1.3.0.1-DeqFZykxniiI9HWlOcxoWI:DhallToCabal

C:\dhall-to-etlas\golden-tests\dhall-to-cabal>del C:\Users\user\AppData\Local\dhall\39919f424375b417e118f94da599d69bbff58b63d418fa7a1bf914005c780f06

C:\dhall-to-etlas\golden-tests\dhall-to-cabal>del C:\Users\user\AppData\Local\dhall\f3ffaa13c8f2e82121145d4602ee38861b7bacbc3427649e1e6a844e448a7159

C:\dhall-to-etlas\golden-tests\dhall-to-cabal>dir C:\Users\user\AppData\Local\dhall /B

C:\dhall-to-etlas\golden-tests\dhall-to-cabal>dhall-to-cabal < dhall-to-cabal-http.dhall
cabal-version: 2.2
<rest of correct cabal output>

Not sure if it is a only dhall-to-cabal issue, but compiling the file with dhall itself works, with and without cache files.

jneira commented 6 years ago

It seems the code expects App ( V0 "v" ) ( TextLit ( Chunks [] text ) ) instead the actual App (Var (V "_" 0)) (TextLit (Chunks [] "1.0.0"))

ocharles commented 6 years ago

Hm, it seems that the variable name is lost here. I think we probably aren't saturating a lamba to get the variable names. Thanks, I'll take a look.

ocharles commented 6 years ago

Can you try the extract-lam branch? It won't fix it everywhere, but it might get further than crashing on v.

jneira commented 6 years ago

Jumm, i've rebased the branch but it throwed some errors compiling with stack. I get to build it adding import qualified Dhall.Core (normalize) and changing

 go =
      \case
        Expr.App ( V0 "v" ) ( Expr.TextLit ( Expr.Chunks [] text ) ) ->
          return ( parse text )

        e ->
          error (show e)

for

 go =
      \case
        Expr.App ( V0 "v" ) ( Expr.TextLit ( Expr.Chunks [] text ) ) ->
          return ( parse text )

        e ->
          error "Error parsing version"

cause it could not infer the Show instance for s0, being e :: Expr.Expr s0 Dhall.TypeCheck.X

Anyway after those changes it throwed the "Error parsing version"

ocharles commented 6 years ago

Oh sorry, I should have actually compiled my code! Interesting, seems that didn't quite get it. I'll look more at this when I get a chance.

jneira commented 6 years ago

Not sure cause not cached version works but maybe it is related with https://github.com/dhall-lang/dhall-lang/pull/203?