Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move (some) of the logic of the dhall executable into Dhall #249

Closed
ocharles opened this issue Feb 2, 2018 · 2 comments
Closed

Move (some) of the logic of the dhall executable into Dhall #249

ocharles opened this issue Feb 2, 2018 · 2 comments

Comments

@ocharles
Copy link
Member

ocharles commented Feb 2, 2018

dhall takes a file, parsers it, resolves imports, type checks, normalizes and then prints - along with a bunch of error checking. A lot of these steps would be useful to have in Dhall. I find myself often playing around in GHCI and wanting a way to take a FilePath and have a Expr s X that is type checked and normalized, but not extracted.

I propose adding

load :: FilePath -> IO (Expr s X)

and having dhall use this. The error checking that dhall does probably gets moved into a new Exception type, with a handler that knows how to print out specific errors.

@Gabriella439
Copy link
Collaborator

Sure! My main suggestions are:

  • Change the argument to a Text value representing Dhall source code. Importing a file then becomes a special case of Dhall's import system, plus you can then load URLs or inline Dhall expressions
  • I recommend naming this rawOutput because there is a similar rawInput function in the Dhall module

@Gabriella439
Copy link
Collaborator

This was fixed by #418, which added new Dhall.inputExpr and Dhall.inputExprWith utilities that do exactly what you requested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants