dhall-lang / dhall-to-cabal

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

Wrong CWD handling #114

Closed quasicomputational closed 6 years ago

quasicomputational commented 6 years ago

Consider running dhall-to-cabal foo/bar.dhall. The input file name could have relative imports, which have to be resolved relative to foo/. However, we read the file and then process it totally divorced of that directory information: we'll try to resolve imports relative to the current working directory.

This isn't trivially fixable in dhall-to-cabal: we need some extra API from dhall itself to specify what directory an expression's imports should be resolved relative to.

ocharles commented 6 years ago

Actually, it's pretty easy - just parse the absolute path to the file as a Dhall expression itself.

quasicomputational commented 6 years ago

Hmm. No guarantee that the file's name is legal in a Dhall expression, though. The other easy hack is to change our CWD, I guess, but that's rude to do in a library.

Oh, wait, dur. This would be done in the executable, not the library. I guess we could do that as a stopgap, but I think it still makes a lot of sense to make dhall properly CWD independent and then we might as well use that API.