lucas' webpage
zettel/data/202209/02T202224/_20220904_182806Captura%20de%20tela%20de%202022-09-04%2018-26-46.png

Ondim

Parent: Development notes
software dashboard

Why Ondim?

Advantages of having the template language built in the target language:

  • No need for special editor support; make use of all the existing tools.
  • Less prone to errors; In some cases, it is even impossible for the templates to result in invalid documents.
  • Context-aware means it’s possible to handle contextual rules like text escaping automatically.
  • Easier to understand visually compared a mix two languages.
  • More modular: no need to write a parser or writer if there are already existing ones.

Known Issues 😳

  • When using withExpansions to bind foo.bar, where foo already exists in the environment, the deletion of foo leaks outside.

Subtemplates hack

  • Some profiling shows one of the mostly costly things when rendering pages is text replacement of attrSub. This is because it parses the same text over and over each time the template is run, countrary to the template itself which is already parsed. I could make the loading functions parse the text once and store the AST as another template that attrSub just calls during expansion.
  • Note to self: difficulties are

    • How to get the text templates from a document in an elegant way. The current way is to run Ondim with errors disabled.
    • How to store the text templates in a place where they can be unloaded along with the file, or if they should not be unloaded (perhaps a source of memory leaks)
    • Text duplicated in memory: bad?
    • Rendering Whiskers/LaTeX ASTs is very slow for odd reasons. Simpler AST?

Store things temporarily NO ARCHIVE

    Say we want an expansion to run inside a monad with extra state, or even other side effects. We want to do that locally, because this inner state does not make sense outside.

    • Note taken on

      This is tricky because the state is parametrized by the inner monad and used in contravariant position. So there cannot be a mapOndim :: Ondim tag m a -> Ondim tag n a without two functions right :: forall a. m a -> n a and left :: forall a. n a -> m a. Without specifying the right semantics, what we are after does not even make sense.

    • Note taken on

      Not that tricky anymore! There was only contravariance in Filter and now I’ve just removed it.

    • Note taken on

      Well, I was wrong above. The mere presence of StateT (F m) is contravariant in m, because it takes the previous state as input. I’ve spent the entire afternoon attempting to make it work, just to realize this. 😢

      So, it’s impossible/not well defined.


    Made with 📖
    Copyright 2023 @lucasvreis