filepather: FilePath and Directory operations via Kleisli type aliases

[ bsd3, library, system, test ] [ Propose Tags ] [ Report a vulnerability ]

Re-implementations of System.FilePath and System.Directory using Kleisli type aliases from the kleisli package. Each function that takes a FilePath as its subject argument is expressed as a Kleisli value, enabling composition via Functor, Applicative, Monad, and other type class instances. Platform-specific modules for Posix and Windows path semantics are also provided.


[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
dev

Enable development warnings (-Werror, -O2 for benchmarks)

Disabled

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

Versions [RSS] 0.3.0, 0.4.0, 0.4.1, 0.5, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.5.5, 0.6.0, 0.6.1
Change log changelog.md
Dependencies adjunctions (>=4.3 && <5), base (>=4.8 && <6), comonad (>=5 && <6), contravariant (>=1 && <2), deepseq (>=1.4 && <2), directory (>=1.3 && <2), distributive (>=0.5 && <1), filepath (>=1.4 && <2), kleisli (>=0.0.3 && <1), lens (>=4 && <6), mtl (>=2.2 && <3), selective (>=0.5 && <1), semigroupoids (>=5.2 && <7), time (>=1.9 && <2), transformers (>=0.5 && <1) [details]
Tested with ghc ==9.6.7
License BSD-3-Clause
Author Tony Morris <tmorris@tmorris.net>
Maintainer Tony Morris <tmorris@tmorris.net>
Uploaded by TonyMorris at 2026-05-27T05:12:34Z
Category System
Home page https://gitlab.com/tonymorris/filepather
Bug tracker https://gitlab.com/tonymorris/filepather/-/issues
Source repo head: git clone https://gitlab.com/tonymorris/filepather.git
Distributions
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 1724 total (20 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-05-27 [all 1 reports]

Readme for filepather-0.6.1

[back to package description]

filepather

Re-implementations of System.FilePath and System.Directory using Kleisli type aliases from the kleisli package.

Each function that takes a FilePath as its subject argument is expressed as a Kleisli value, enabling composition via Functor, Applicative, Monad, and other type class instances.

Modules

Module Description
System.FilePather Re-exports the platform-native module
System.FilePather.FilePather Platform-native filepath and directory operations
System.FilePather.FilePather.Posix Posix filepath operations
System.FilePather.FilePather.Windows Windows filepath operations

Type aliases

type FilePather  p f a = Kleisli p FilePath f a
type FilePather' p a   = FilePather p Identity a
type FilePatherA f a   = FilePather (->) f a
type FilePatherA' a    = FilePatherA Identity a

Usage

import System.FilePather
import Data.Kleisli (Kleisli(..))
import Data.Functor.Identity (runIdentity)

-- Pure operations return FilePatherA' (Kleisli (->) FilePath Identity a)
-- >>> runIdentity (let Kleisli f = takeExtension in f "/foo/bar.hs")
-- ".hs"

-- Effectful operations return FilePatherA IO a (Kleisli (->) FilePath IO a)
-- >>> let Kleisli f = doesFileExist in f "/tmp/example.txt"
-- False

-- Partial operations return FilePatherA Maybe a
-- >>> let Kleisli f = stripExtension ".hs" in f "/foo/bar.hs"
-- Just "/foo/bar"

-- Compose with Functor/Applicative/Monad instances
-- >>> runIdentity (let Kleisli f = fmap (++ ".bak") takeFileName in f "/tmp/notes.txt")
-- "notes.txt.bak"

Building

cabal build
cabal test doctest
cabal bench