path-dhall-instance 0.1.1.0 → 0.2.0.0
raw patch · 4 files changed
+34/−9 lines, 4 filesdep +eitherdep +textdep −aesonPVP ok
version bump matches the API change (PVP)
Dependencies added: either, text
Dependencies removed: aeson
API changes (from Hackage documentation)
+ Path.Dhall: pathDecoder :: Show a1 => (FilePath -> Either a1 a2) -> InputNormalizer -> Decoder a2
Files
- ChangeLog.md +4/−0
- README.md +0/−2
- path-dhall-instance.cabal +4/−3
- src/Path/Dhall.hs +26/−4
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for path-dhall-instance +# v0.2.0.0++* Directory normalisation now works.+ # v0.1.0.1 * `FromDhall` and `ToDhall` instances for `Path`.
README.md view
@@ -1,5 +1,3 @@ # path-dhall-instance `FromDhall` and `ToDhall` instances for [path](https://hackage.haskell.org/package/path).--Warning: This is not currently normalizing anything when parsing, because I don't understand dhall's instances.
path-dhall-instance.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: path-dhall-instance-version: 0.1.1.0+version: 0.2.0.0 synopsis: ToDhall and FromDhall instances for Path. description: ToDhall and FromDhall instances for Path. category: Filesystem@@ -27,8 +27,9 @@ hs-source-dirs: src build-depends:- aeson- , base >=4.7 && <5+ base >=4.7 && <5 , dhall+ , either , path+ , text default-language: Haskell2010
src/Path/Dhall.hs view
@@ -7,14 +7,36 @@ -} {-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE RecordWildCards #-} module Path.Dhall where -import Data.Aeson import Dhall+import qualified Data.Text as T import Path+import Data.Either.Validation -instance FromDhall (Path Rel File)-instance FromDhall (Path Rel Dir)+pathDecoder f opts =+ Decoder+ { extract = extractPath+ , expected = expectedPath+ }+ where+ filePathDecoder :: Decoder FilePath+ filePathDecoder = autoWith opts++ extractPath expression =+ case extract filePathDecoder expression of+ Success x -> case f x of+ Left exception -> Dhall.extractError (T.pack $ show exception)+ Right path -> Success path+ Failure e -> Failure e++ expectedPath = expected filePathDecoder++instance FromDhall (Path Rel Dir) where+ autoWith options = pathDecoder parseRelDir options++instance FromDhall (Path Rel File) where+ autoWith options = pathDecoder parseRelFile options+ instance ToDhall (Path Rel File) instance ToDhall (Path Rel Dir)