MIT licensed by Daniel Firth
Maintained by [email protected]
This version can be pinned in stack with:within-0.2.0.1@sha256:dc0a0cbd5143ef0a78d18a32424b570df901eb645d6a9347e6585e74125f5959,1222

Module documentation for 0.2.0.1

Within

Within is a type for simply scoping well-typed paths. A Within b a is simply an Env comonad with the environment specialised to Path b Dir. This is useful for when you want to keep track of things that live within a parent folder and need the extra degree of articulation. You can construct a value a living within a Path b Dir using the within infix operator.

5 `within` $(mkRelDir "foo")

There are also convenience functions for dealing with the special case where the inner type is a Path Rel File, which represents a path to a file within a directory. This does not need to be an immediate child of the directory, and does not have to exist. You can assert that you can assert that an existing path lies in a directory by using asWithin, which throws if the directory is not a proper prefix of the Path.

$(mkRelFile "foo/a.txt") `asWithin` $(mkRelDir "foo") -- fine
$(mkRelFile "a.txt") `asWithin` $(mkRelDir "foo") -- throws NotAProperPrefix Exception

You can also use fromWithin to get from a Within a (Path Rel t) to a Path a t.

There are also Eq, Show and Hashable instances when the extract target is of that class.

Changes

Changelog for within

v0.2.0.0

v0.1.0.0

  • Change approach to ComonadEnv style newtype. Within can now store an arbitrary inner type whilst maintaining the convenience functions in the special case where the inner type is a Path.

v0.0.2.0

  • Add Hashable and Ord instances for Within.

v0.0.1.0

  • Add Within Type based on path. Within is a path within another path.
  • Add several functions for moving between directories and mapping source names.