within 0.1.1.0 → 0.2.0.0
raw patch · 5 files changed
+35/−16 lines, 5 filesdep +path-likesetup-changed
Dependencies added: path-like
Files
- ChangeLog.md +5/−5
- LICENSE +1/−1
- Setup.hs +0/−2
- src/Within.hs +21/−5
- within.cabal +8/−3
ChangeLog.md view
@@ -1,14 +1,14 @@ # Changelog for within -## v0.1.1.0+## v0.2.0.0 -Readd missing instances.+* Add [path-like](https://hackage.haskell.org/package/path-like) and `PathLike` instance. ## 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`.+* 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
LICENSE view
@@ -1,4 +1,4 @@-Copyright Author name here (c) 2020+Copyright Daniel Firth (c) 2020 All rights reserved.
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
src/Within.hs view
@@ -1,9 +1,18 @@-{-# LANGUAGE DeriveFoldable #-}-{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveTraversable #-}+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE UndecidableInstances #-}+{- |+ Module : Path.Like+ Copyright : Copyright (C) 2020 Daniel Firth+ Maintainer : Daniel Firth <dan.firth@homotopic.tech>+ License : MIT+ Stability : experimental++The Within type, an EnvT comonad specialised to `Path b Dir`.+-} module Within ( WithinT(..) , Within@@ -28,6 +37,7 @@ import Data.Typeable import GHC.Generics import Path+import Path.Like -- | The Within Type, newtype wrapper around `EnvT` specialised to a `Path b Dir` environment. newtype WithinT b w a = WithinT (EnvT (Path b Dir) w a)@@ -67,9 +77,15 @@ within :: a -> Path b Dir -> Within b a within x y = WithinT (EnvT y (Identity x)) --- | Turns a `Within` containing a path into a single path.-fromWithin :: Within a (Path Rel t) -> Path a t-fromWithin = liftA2 (</>) ask extract+-- | Turns a `Within` containing a `PathLike` into a single `Path`.+fromWithin :: PathLike Rel t a => Within b a -> Path b t+fromWithin = liftA2 (</>) ask (toPath . extract)++instance PathLike Rel t a => PathLike b t (Within b a) where+ toPath = fromWithin++instance FileLike Rel a => FileLike b (Within b a)+instance DirLike Rel a => DirLike b (Within b a) instance Eq t => Eq (Within b t) where WithinT (EnvT e (Identity a)) == WithinT (EnvT e' (Identity a')) = e == e' && a == a'
within.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0.+-- This file has been generated from package.yaml by hpack version 0.34.2. -- -- see: https://github.com/sol/hpack ----- hash: c01a2f87b3dc8101e86b077b7ced2de7735d4ec13ec92d36ee17a60798fde570+-- hash: 8717fa1b57121b98ec2dc642105acd188f8ca914cbebaf65a0cf02877a3529ee name: within-version: 0.1.1.0+version: 0.2.0.0 synopsis: A value within another path. description: 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. category: Filesystem@@ -21,6 +21,10 @@ README.md ChangeLog.md +source-repository head+ type: git+ location: https://gitlab.com/homotopic-tech/within+ library exposed-modules: Within@@ -36,4 +40,5 @@ , free , hashable , path+ , path-like >=0.2.0.0 default-language: Haskell2010