unionmount-0.2.2.0: Union mount filesystem paths into Haskell datastructures
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.UnionMount

Synopsis

Mount endpoints

mount Source #

Arguments

:: forall model m b. (MonadIO m, MonadUnliftIO m, MonadLogger m, Show b, Ord b) 
=> FilePath

The directory to mount.

-> [(b, FilePattern)]

Only include these files (exclude everything else)

-> [FilePattern]

Ignore these patterns

-> model

Initial value of model, onto which to apply updates.

-> (b -> FilePath -> FileAction () -> m (model -> model))

How to update the model given a file action.

b is the tag associated with the FilePattern that selected this FilePath. FileAction is the operation performed on this path. This should return a function (in monadic context) that will update the model, to reflect the given FileAction.

If the action throws an exception, it will be logged and ignored.

-> m (model, (model -> m ()) -> m ()) 

Simplified version of unionMount with exactly one layer.

unionMount :: forall source tag model m. (MonadIO m, MonadUnliftIO m, MonadLogger m, Ord source, Ord tag) => Set (source, FilePath) -> [(tag, FilePattern)] -> [FilePattern] -> model -> (Change source tag -> m (model -> model)) -> m (model, (model -> m ()) -> m ()) Source #

Union mount a set of sources (directories) into a model.

unionMount' :: forall source tag m m1. (MonadIO m, MonadUnliftIO m, MonadLogger m, MonadLogger m1, MonadIO m1, Ord source, Ord tag) => Set (source, FilePath) -> [(tag, FilePattern)] -> [FilePattern] -> m1 (Change source tag, (Change source tag -> m ()) -> m Cmd) Source #

Like unionMount but without exception interrupting or re-mounting.

Types

data FileAction a Source #

Constructors

Refresh RefreshAction a

A new file, or updated file, is available

Delete

The file just got deleted.

Instances

Instances details
Functor FileAction Source # 
Instance details

Defined in System.UnionMount

Methods

fmap :: (a -> b) -> FileAction a -> FileAction b #

(<$) :: a -> FileAction b -> FileAction a #

Show a => Show (FileAction a) Source # 
Instance details

Defined in System.UnionMount

Eq a => Eq (FileAction a) Source # 
Instance details

Defined in System.UnionMount

Methods

(==) :: FileAction a -> FileAction a -> Bool #

(/=) :: FileAction a -> FileAction a -> Bool #

data RefreshAction Source #

Constructors

Existing

No recent change. Just notifying of file's existance

New

New file got created

Update

The already existing file was updated.

Instances

Instances details
Show RefreshAction Source # 
Instance details

Defined in System.UnionMount

Eq RefreshAction Source # 
Instance details

Defined in System.UnionMount

type Change source tag = Map tag (Map FilePath (FileAction (NonEmpty (source, FilePath)))) Source #