unionmount

unionmount is a Haskell library that wraps fsnotify to provide a Dynamic-friendly API to listen on filesystem changes and update an in-memory Model type. The library interface is such that you can “mount” multiple directories (union'ing them in the process), and have it update the model when files on any of those directories change.

Emanote uses it to monitor Markdown files (and other files) in its layers.

Links to this page
  • Model type
    unionmount - mounting local files into Haskell in-memory model with change updates.
  • Hot Reload

    Finally, hot reload on code changes are supported via ghcid. The template repo's `bin/run` script uses ghcid underneath. Any HTML DSL (like blaze-html) or CSS DSL automatically gets supported for hot-reload. If you choose to use a file-based HTML template language, you can enable hot-reload on template change using the unionmount library.

    For anything outside of the Haskell code, your code becomes responsible for monitoring and updating the Model type Dynamic. The unionmount library already provides utilities to facilitate this for monitoring changes to files and directories.

  • Dynamic Model

    In the case of our mood tracker, we will use the fsnotify package (see unionmount for another option) to fulfill that <some func that returns the next update> part. So, without further ado, here’s the full implementation of the new siteInput that produces a fully-fledged Dynamic m Model:

  • Dynamic

    The use of a time-varying Dynamic is what enables Hot Reload. See here for an example of making a model time-varying. Checkout unionmount to produce a Dynamic of a model that updates based on the filesystem tree.