Some context for this idea – I’m currently intending to use dhall as a templating language with multiple outputs – latex and HTML. I already have a system in place, but I’d like to migrate things to dhall fully.
The actual raw copy I intend on writing in markdown, and in my current non-dhall system they are being translated into html or latex appropriately.
This markdown-to-html or markdown-to-latex process is the current thing that is makes things a little painful. markdown-to-html I can sort of fix by loading a client-side js markdown library, which works but is unideal. markdown-to-latex my current solution is to use dhall to generate a yaml file, and then use pandoc’s templating on that yaml file, but I’d really prefer to not have to require any templating system outside of dhall.
Ideally I’d like something that only needs to leverage the
dhall shell tool and other shell scripts, and not have to spin up an entire programming language to write something, otherwise there wouldn’t be much gain from what I am currently doing.
So, here’s my idea! Currently,
dhall text only renders
Text as far as I know. But, we could maybe extend it to rendering
Text -> Text, as well, by calling as
dhall --textarg "hello", which feeds in a string at runtime, applies it to the function, and renders the resulting final
Text. And, what if it could also render
(Text -> Text) -> Text functions, as well, by calling as
dhall --shellarg "pandoc -f markdown -t html". Then in the dhall expression
\(f : Text -> Text) -> .., it would invoke the shell function in stdin-stdout mode to get that
Text -> Text, so I could write a dhall expression like
\(renderMarkdown : Text -> Text) -> .. and have a markdown rendering function. It would be assumed (or gently suggested) that the shell command given must be pure (return the same stdout for every stdin, and change nothing major about its state on every invocation) for this to make sense.
I could probably dive in to implementing this myself. Dhall evaluation resolution is already in IO iirc, so I think this could work.
Let me know if there is a better way to achieve this, though! Or if this feature is too heavy or convoluted to be worth including into the dhall tool, and I can maybe try to figure out other workarounds or stick with the ones I already mentioned