Open j-rockel opened 1 year ago
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
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?
Oh yeah, in the latter toSplitDhall
example you'd have to change it to Expr Src Import
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:
embed
anddeclared
are limited to import free expressionsAm 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?