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

Translate to dhall as a collection of expressions connected by imports #2476

Open
j-rockel opened this issue Dec 15, 2022 · 3 comments
Open

Comments

@j-rockel
Copy link

This is more of a "is there any way to do this / could this functionality be supported in future" question rather than an issue:

When translating from haskell to dhall, I want to have my output be a collection of dhall files connected by imports rather than one big file. Currently I'm doing this by translating and then traversing the resulting dhall expression, splitting out subexpressions and replacing them with import statements, but I would much prefer to be able to mark a split point in the haskell representation rather than having to scan for it in the dhall expression.

The two initial ideas I had for this are both currently not supported as far as I can tell:

  1. A custom ToDhall instance that would produce an import statement / an expression containing imports / a list of expressions containing imports and their respective subpaths ... -> can't do that bc the types of embed and declared are limited to import free expressions
  2. Build my own ToSplitDhall typeclass to do this -> the problem with this is a bit harder to express but I think the core of the issue here is that I can't find a way to build an expression with a hole that I can slot an existing subexpression into

Am I missing something and there is already a way to do this?
If not, was it intentionally omitted or just hasn't been needed so far?

@Gabriella439
Copy link
Collaborator

Yeah, you wouldn't be able to do this using ToDhall since they can only emit a single Expr and not, say, a directory tree of expressions.

If you were to try to create a ToSplitDhall type class, I think what you'd want is something like:

toSplitDhall :: a -> DirectoryTree (Expr Src Void)

… where DirectoryTree is some pure representation of a directory tree

@j-rockel
Copy link
Author

j-rockel commented Dec 19, 2022

yeah that's what I thought, but even then I am still restricted to Expr Src Void so no imports (unless I purposely misuse the import type parameter, which I'd rather not), meaning I would still have to go through the resulting expressions and replace subexpressions with import statements, right?

@Gabriella439
Copy link
Collaborator

Oh yeah, in the latter toSplitDhall example you'd have to change it to Expr Src Import

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