polysemy-path 0.2.0.0 → 0.2.1.0
raw patch · 3 files changed
+130/−108 lines, 3 filesdep −polysemy-plugindep ~basedep ~pathdep ~polysemyPVP ok
version bump matches the API change (PVP)
Dependencies removed: polysemy-plugin
Dependency ranges changed: base, path, polysemy, polysemy-extra
API changes (from Hackage documentation)
Files
- ChangeLog.md +4/−0
- polysemy-path.cabal +6/−7
- src/Polysemy/Path.hs +120/−101
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for polysemy-path +## v0.2.1.0++* Remove dependency on polysemy-zoo.+ ## v0.2.0.0 * Re-export the rest of path-0.8.0.
polysemy-path.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.2.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack name: polysemy-path-version: 0.2.0.0+version: 0.2.1.0 synopsis: Polysemy versions of Path functions. category: Polysemy author: Daniel Firth@@ -31,9 +31,8 @@ src ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints build-depends:- base >=4.7 && <5- , path >=0.8.0 && <0.9- , polysemy- , polysemy-extra >=0.1.7.0 && <0.2.0.0- , polysemy-plugin+ base >=4.7 && <4.16+ , path >=0.8.0 && <0.10+ , polysemy >=1.3.0.0 && <1.7+ , polysemy-extra >=0.1.7.0 && <0.3 default-language: Haskell2010
src/Polysemy/Path.hs view
@@ -1,150 +1,169 @@-{-|-Module : Polysemy.Path-License : MIT-Maintainer : dan.firth@homotopic.tech-Stability : experimental--Polysemy versions of functions in the path library.--}-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE GADTs #-}-{-# LANGUAGE PolyKinds #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-}-{-# OPTIONS_GHC -fplugin=Polysemy.Plugin #-}-module Polysemy.Path (- Path-, Rel-, Abs-, File-, Dir-, SomeBase-, PathException-, Path.absdir-, Path.reldir-, Path.absfile-, Path.relfile-, (Path.</>)-, stripProperPrefix-, Path.isProperPrefixOf-, Path.parent-, Path.filename-, Path.dirname-, addExtension-, splitExtension-, fileExtension-, replaceExtension-, parseRelFile-, parseAbsFile-, parseRelDir-, parseAbsDir-, parseSomeDir-, parseSomeFile-, Path.toFilePath-, Path.fromAbsDir-, Path.fromRelDir-, Path.fromAbsFile-, Path.fromRelFile-, Path.fromSomeDir-, Path.fromSomeFile-, Path.mkAbsDir-, Path.mkRelDir-, Path.mkAbsFile-, Path.mkRelFile-) where+{-# LANGUAGE TypeApplications #-}+{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} +-- |+-- Module : Polysemy.Path+-- License : MIT+-- Maintainer : dan.firth@homotopic.tech+-- Stability : experimental+--+-- Polysemy versions of functions in the path library.+module Polysemy.Path+ ( Path,+ Rel,+ Abs,+ File,+ Dir,+ SomeBase,+ PathException,+ Path.absdir,+ Path.reldir,+ Path.absfile,+ Path.relfile,+ (Path.</>),+ stripProperPrefix,+ Path.isProperPrefixOf,+ Path.parent,+ Path.filename,+ Path.dirname,+ addExtension,+ splitExtension,+ fileExtension,+ replaceExtension,+ parseRelFile,+ parseAbsFile,+ parseRelDir,+ parseAbsDir,+ parseSomeDir,+ parseSomeFile,+ Path.toFilePath,+ Path.fromAbsDir,+ Path.fromRelDir,+ Path.fromAbsFile,+ Path.fromRelFile,+ Path.fromSomeDir,+ Path.fromSomeFile,+ Path.mkAbsDir,+ Path.mkRelDir,+ Path.mkAbsFile,+ Path.mkRelFile,+ )+where++import Control.Exception+import Path (Abs, Dir, File, Path, PathException, Rel, SomeBase) import qualified Path-import Path (Path, Rel, Abs, File, Dir, SomeBase, PathException) import Polysemy import Polysemy.Error-import Polysemy.Extra +-- | Irrefutably absorb a `PathException`. Use with extreme care.+irrefutablePathException :: (Members '[Error PathException] r) => Either SomeException a -> Sem r a+irrefutablePathException x = case x of+ Left e -> let Just e' = Control.Exception.fromException @PathException e in Polysemy.Error.throw e'+ Right a -> pure a+ -- | Polysemy version of `Path.parseRelFile`. -- -- @since 0.1.0.0-parseRelFile :: Members '[Error PathException] r- => FilePath- -> Sem r (Path Rel File)-parseRelFile x = irrefutableAbsorbThrow (Path.parseRelFile x)+parseRelFile ::+ Members '[Error PathException] r =>+ FilePath ->+ Sem r (Path Rel File)+parseRelFile x = irrefutablePathException (Path.parseRelFile x) -- | Polysemy version of `Path.parseAbsFile`. -- -- @since 0.1.0.0-parseAbsFile :: Members '[Error PathException] r- => FilePath- -> Sem r (Path Abs File)-parseAbsFile x = irrefutableAbsorbThrow (Path.parseAbsFile x)+parseAbsFile ::+ Members '[Error PathException] r =>+ FilePath ->+ Sem r (Path Abs File)+parseAbsFile x = irrefutablePathException (Path.parseAbsFile x) -- | Polysemy version of `Path.parseRelDir`. -- -- @since 0.1.0.0-parseRelDir :: Members '[Error PathException] r- => FilePath- -> Sem r (Path Rel Dir)-parseRelDir x = irrefutableAbsorbThrow (Path.parseRelDir x)+parseRelDir ::+ Members '[Error PathException] r =>+ FilePath ->+ Sem r (Path Rel Dir)+parseRelDir x = irrefutablePathException (Path.parseRelDir x) -- | Polysemy version of `Path.parseAbsDir`. -- -- @since 0.1.0.0-parseAbsDir :: Members '[Error PathException] r- => FilePath- -> Sem r (Path Abs Dir)-parseAbsDir x = irrefutableAbsorbThrow (Path.parseAbsDir x)+parseAbsDir ::+ Members '[Error PathException] r =>+ FilePath ->+ Sem r (Path Abs Dir)+parseAbsDir x = irrefutablePathException (Path.parseAbsDir x) -- | Polysemy version of `Path.parseSomeDir`. -- -- @since 0.2.0.0-parseSomeDir :: Members '[Error PathException] r- => FilePath- -> Sem r (SomeBase Dir)-parseSomeDir x = irrefutableAbsorbThrow (Path.parseSomeDir x)+parseSomeDir ::+ Members '[Error PathException] r =>+ FilePath ->+ Sem r (SomeBase Dir)+parseSomeDir x = irrefutablePathException (Path.parseSomeDir x) -- | Polysemy version of `Path.parseSomeFile`. -- -- @since 0.2.0.0-parseSomeFile :: Members '[Error PathException] r- => FilePath- -> Sem r (SomeBase File)-parseSomeFile x = irrefutableAbsorbThrow (Path.parseSomeFile x)+parseSomeFile ::+ Members '[Error PathException] r =>+ FilePath ->+ Sem r (SomeBase File)+parseSomeFile x = irrefutablePathException (Path.parseSomeFile x) -- | Polysemy version of `Path.stripProperPrefix`. -- -- @since 0.1.0.0-stripProperPrefix :: Members '[Error PathException] r- => Path b Dir- -> Path b t- -> Sem r (Path Rel t)-stripProperPrefix x y = irrefutableAbsorbThrow (Path.stripProperPrefix x y)+stripProperPrefix ::+ Members '[Error PathException] r =>+ Path b Dir ->+ Path b t ->+ Sem r (Path Rel t)+stripProperPrefix x y = irrefutablePathException (Path.stripProperPrefix x y) -- | Polysemy version of `Path.addExtension`. -- -- @since 0.2.0.0-addExtension :: Members '[Error PathException] r- => String- -> Path b File- -> Sem r (Path b File)-addExtension x y = irrefutableAbsorbThrow (Path.addExtension x y)+addExtension ::+ Members '[Error PathException] r =>+ String ->+ Path b File ->+ Sem r (Path b File)+addExtension x y = irrefutablePathException (Path.addExtension x y) -- | Polysemy version of `Path.splitExtension`. -- -- @since 0.2.0.0-splitExtension :: Members '[Error PathException] r- => Path b File- -> Sem r (Path b File, String)-splitExtension x = irrefutableAbsorbThrow (Path.splitExtension x)+splitExtension ::+ Members '[Error PathException] r =>+ Path b File ->+ Sem r (Path b File, String)+splitExtension x = irrefutablePathException (Path.splitExtension x) -- | Polysemy version of `Path.replaceExtension`. -- -- @since 0.2.0.0-replaceExtension :: Members '[Error PathException] r- => String- -> Path b File- -> Sem r (Path b File)-replaceExtension x y = irrefutableAbsorbThrow (Path.replaceExtension x y)+replaceExtension ::+ Members '[Error PathException] r =>+ String ->+ Path b File ->+ Sem r (Path b File)+replaceExtension x y = irrefutablePathException (Path.replaceExtension x y) -- | Polysemy version of `Path.fileExtension`. -- -- @since 0.2.0.0-fileExtension :: Members '[Error PathException] r- => Path b File- -> Sem r String-fileExtension x = irrefutableAbsorbThrow (Path.fileExtension x)+fileExtension ::+ Members '[Error PathException] r =>+ Path b File ->+ Sem r String+fileExtension x = irrefutablePathException (Path.fileExtension x)