unionmount: Union mount filesystem paths into Haskell datastructures

[ filesystem, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

Union mount filesystem paths into Haskell datastructures


[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
ghcidDisabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2.0.0, 0.2.2.0, 0.3.0.0
Dependencies async, base (>=4.13.0 && <5), bytestring, containers, data-default, directory, filepath, filepattern, fsnotify (>=0.4.0 && <0.5), lvar, monad-logger, mtl, relude, text, time, unliftio, with-utf8 [details]
License MIT
Copyright 2021 Sridhar Ratnakumar
Author Sridhar Ratnakumar
Maintainer srid@srid.ca
Category Filesystem
Bug tracker https://github.com/srid/unionmount
Uploaded by sridca at 2025-08-19T01:26:15Z
Distributions NixOS:0.2.2.0
Reverse Dependencies 4 direct, 1 indirect [details]
Downloads 366 total (9 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2025-08-19 [all 1 reports]

Readme for unionmount-0.3.0.0

[back to package description]

unionmount

Haskell library to "union mount" a bunch of folders onto an in-memory data structure, and keeping the latter in sync as the files change over time. Used in Ema and Emanote.

Usage

Both the mount and unionMount functions return a tuple value of type Dynamic, giving direct access to the initial value as well as the updater function that may be run in a separate thread. See how Ema uses it for an illustration.

Here's a simple example of loading Markdown files onto a TVar of Map FilePath Text (file contents keyed by path).

import System.UnionMount qualified as UM
import Data.Map.Strict qualified as Map

main :: IO ()
main = do
  runStdoutLoggingT $ do
    let baseDir = "/Users/srid/Documents/Notebook"
    (model0, modelF) <- UM.mount baseDir (one ((), "*.md")) [] mempty (const $ handlePathUpdate baseDir)
    modelVar <- newTVarIO model0
    modelF $ \newModel -> do
      atomically $ writeTVar modelVar newModel

handlePathUpdate ::
  (MonadIO m) =>
  FilePath -> FilePath -> UM.FileAction () -> m (Map FilePath Text -> Map FilePath Text)
handlePathUpdate baseDir path action = do
  case action of
    UM.Refresh _ _ -> do
      s <- decodeUtf8 <$> readFileBS (baseDir </> path)
      pure $ Map.insert path s
    UM.Delete -> do
      pure $ Map.delete path

Examples

See this example illustrating mounting a directory of Markdown files into (effectively) a Map FilePath String. A more involved example from Emanote demonstrates the "union" aspect of the library.