Closed quasicomputational closed 6 years ago
Actually, it's pretty easy - just parse the absolute path to the file as a Dhall expression itself.
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.
Consider running
dhall-to-cabal foo/bar.dhall
. The input file name could have relative imports, which have to be resolved relative tofoo/
. 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.