path-like 0.1.0.0 → 0.1.1.0
raw patch · 4 files changed
+23/−12 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Path.Like: class PathLike b t a | a -> b, a -> t
+ Path.Like: instance Path.Like.PathLike b t (Path.Internal.Path b t)
+ Path.Like: toPath :: PathLike b t a => a -> Path b t
- Path.Like: class DirLike b a | a -> b
+ Path.Like: class PathLike b Dir a => DirLike b a
- Path.Like: class FileLike b a | a -> b
+ Path.Like: class PathLike b File a => FileLike b a
Files
- ChangeLog.md +4/−0
- README.md +1/−1
- path-like.cabal +3/−3
- src/Path/Like.hs +15/−8
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for path-like +## (v0.1.1.0)++* Add 'PathLike` superclass to `FileLike` and `DirLike`.+ ## (v0.1.0.0) * Add `FileLike` and `DirLike` type class for using stricter types as `Path b File` and `Path b Dir` respectively.
README.md view
@@ -1,6 +1,6 @@ # path-like - Type classes for the Path library. -This library exports two type classes `FileLike` and `DirLike` which serve as a+This library exports type classes `PathLike`, `FileLike` and `DirLike` which serve as a common interface for compiling types down to `Path b File` and `Path b Dir`. The only contract that should be respected is that your type should be at least as strict as the `Path` type itself, i.e no String/FilePath instances. This is
path-like.cabal view
@@ -5,9 +5,9 @@ -- see: https://github.com/sol/hpack name: path-like-version: 0.1.0.0-synopsis: FileLike and DirLike type classes for the Path library.-description: Type classes for the Path library. Exports FileLike and DirLike classes so that stricter types may be used as Paths.+version: 0.1.1.0+synopsis: PathLike, FileLike and DirLike type classes for the Path library.+description: Type classes for the Path library. Exports PathLike, FileLike and DirLike classes so that stricter types may be used as Paths. category: Filesystem author: Daniel Firth maintainer: dan.firth@homotopic.tech
src/Path/Like.hs view
@@ -13,26 +13,33 @@ -} module Path.Like (- FileLike(..)+ PathLike(..)+, FileLike(..) , DirLike(..) , (/>) ) where import Path +-- | Class representing a type `a` that can be compiled down to a `Path b t`.+class PathLike b t a | a -> b, a -> t where+ toPath :: a -> Path b t+ -- | Class representing a type `a` that can be compiled down to a `Path b File`.-class FileLike b a | a -> b where+class PathLike b File a => FileLike b a where toFile :: a -> Path b File+ toFile = toPath --- | Class representing a type `a` that can be compiled down to a `Path b Dir`.-class DirLike b a | a -> b where+-- | Class repreenting a type `a` that can be compiled down to a `Path b Dir`.+class PathLike b Dir a => DirLike b a where toDir :: a -> Path b Dir+ toDir = toPath -instance FileLike b (Path b File) where- toFile = id+instance PathLike b t (Path b t) where+ toPath = id -instance DirLike b (Path b Dir) where- toDir = id+instance FileLike b (Path b File)+instance DirLike b (Path b Dir) -- | Like `Path.</>`, but works for any `DirLike` and relative `FileLike` to produce a concrete `Path`. (/>) :: (DirLike b a, FileLike Rel c) => a -> c -> Path b File