path-like 0.1.2.0 → 0.2.0.0
raw patch · 3 files changed
+18/−14 lines, 3 files
Files
- ChangeLog.md +2/−2
- path-like.cabal +1/−1
- src/Path/Like.hs +15/−11
ChangeLog.md view
@@ -1,8 +1,8 @@ # Changelog for path-like -## (v0.1.2.0)+## (v0.2.0.0) -* Change to ConstraintKinds style.+* Revert ConstraintKinds mess. ## (v0.1.1.0)
path-like.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: path-like-version: 0.1.2.0+version: 0.2.0.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
src/Path/Like.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FunctionalDependencies #-}@@ -15,10 +14,8 @@ module Path.Like ( PathLike(..)-, FileLike-, DirLike-, toFile-, toDir+, FileLike(..)+, DirLike(..) , (/>) ) where @@ -28,14 +25,21 @@ class PathLike b t a | a -> b, a -> t where toPath :: a -> Path b t -type FileLike b a = PathLike b File a-type DirLike b a = PathLike b Dir a+-- | Class representing a type `a` that can be compiled down to a `Path b File`.+class PathLike b File a => FileLike b a where+ toFile :: a -> Path b File+ toFile = toPath -toFile :: FileLike b a => a -> Path b File-toFile = toPath+-- | 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 -toDir :: DirLike b a => a -> Path b Dir-toDir = toPath+instance PathLike b t (Path b t) where+ toPath = 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