within: A value within another path.

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

Simple newtype for representing a value within a well-typed directory. Useful for when you need to jump between directories and change filenames independently. Uses the path library.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.0.1.0, 0.0.1.1, 0.0.2.0, 0.1.0.0, 0.1.0.1, 0.1.1.0, 0.2.0.0, 0.2.0.1
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), comonad, exceptions, free, hashable, path, path-like (>=0.2.0.0) [details]
License MIT
Copyright 2020 Daniel Firth
Author Daniel Firth
Maintainer dan.firth@homotopic.tech
Category Filesystem
Source repo head: git clone https://gitlab.com/homotopic-tech/within
Uploaded by locallycompact at 2020-08-28T14:39:07Z
Distributions LTSHaskell:0.2.0.1, NixOS:0.2.0.1
Reverse Dependencies 3 direct, 0 indirect [details]
Downloads 1904 total (12 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-08-28 [all 1 reports]

Readme for within-0.2.0.1

[back to package description]

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.