path-pieces 0.2.0 → 0.2.1
raw patch · 2 files changed
+29/−1 lines, 2 filesdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base
API changes (from Hackage documentation)
- Web.PathPieces: instance PathPiece Bool
- Web.PathPieces: instance PathPiece Day
- Web.PathPieces: instance PathPiece Int
- Web.PathPieces: instance PathPiece Int16
- Web.PathPieces: instance PathPiece Int32
- Web.PathPieces: instance PathPiece Int64
- Web.PathPieces: instance PathPiece Int8
- Web.PathPieces: instance PathPiece Integer
- Web.PathPieces: instance PathPiece String
- Web.PathPieces: instance PathPiece Text
- Web.PathPieces: instance PathPiece Word
- Web.PathPieces: instance PathPiece Word16
- Web.PathPieces: instance PathPiece Word32
- Web.PathPieces: instance PathPiece Word64
- Web.PathPieces: instance PathPiece Word8
- Web.PathPieces: instance PathPiece a => PathMultiPiece [a]
- Web.PathPieces: instance PathPiece a => PathPiece (Maybe a)
+ Web.PathPieces: instance Web.PathPieces.PathPiece ()
+ Web.PathPieces: instance Web.PathPieces.PathPiece Data.Text.Internal.Lazy.Text
+ Web.PathPieces: instance Web.PathPieces.PathPiece Data.Text.Internal.Text
+ Web.PathPieces: instance Web.PathPieces.PathPiece Data.Time.Calendar.Days.Day
+ Web.PathPieces: instance Web.PathPieces.PathPiece GHC.Base.String
+ Web.PathPieces: instance Web.PathPieces.PathPiece GHC.Int.Int16
+ Web.PathPieces: instance Web.PathPieces.PathPiece GHC.Int.Int32
+ Web.PathPieces: instance Web.PathPieces.PathPiece GHC.Int.Int64
+ Web.PathPieces: instance Web.PathPieces.PathPiece GHC.Int.Int8
+ Web.PathPieces: instance Web.PathPieces.PathPiece GHC.Integer.Type.Integer
+ Web.PathPieces: instance Web.PathPieces.PathPiece GHC.Types.Bool
+ Web.PathPieces: instance Web.PathPieces.PathPiece GHC.Types.Int
+ Web.PathPieces: instance Web.PathPieces.PathPiece GHC.Types.Word
+ Web.PathPieces: instance Web.PathPieces.PathPiece GHC.Word.Word16
+ Web.PathPieces: instance Web.PathPieces.PathPiece GHC.Word.Word32
+ Web.PathPieces: instance Web.PathPieces.PathPiece GHC.Word.Word64
+ Web.PathPieces: instance Web.PathPieces.PathPiece GHC.Word.Word8
+ Web.PathPieces: instance Web.PathPieces.PathPiece a => Web.PathPieces.PathMultiPiece [a]
+ Web.PathPieces: instance Web.PathPieces.PathPiece a => Web.PathPieces.PathPiece (GHC.Base.Maybe a)
+ Web.PathPieces: readFromPathPiece :: Read s => Text -> Maybe s
+ Web.PathPieces: showToPathPiece :: Show s => s -> Text
Files
- Web/PathPieces.hs +28/−0
- path-pieces.cabal +1/−1
Web/PathPieces.hs view
@@ -2,6 +2,8 @@ module Web.PathPieces ( PathPiece (..) , PathMultiPiece (..)+ , readFromPathPiece+ , showToPathPiece -- * Deprecated , toSinglePiece , toMultiPiece@@ -16,11 +18,16 @@ import qualified Data.Text.Read import Data.Time (Day) import Control.Exception (assert)+import Text.Read (readMaybe) class PathPiece s where fromPathPiece :: S.Text -> Maybe s toPathPiece :: s -> S.Text +instance PathPiece () where+ fromPathPiece t = if t == "_" then Just () else Nothing+ toPathPiece () = "_"+ instance PathPiece String where fromPathPiece = Just . S.unpack toPathPiece = S.pack@@ -121,6 +128,27 @@ instance PathPiece a => PathMultiPiece [a] where fromPathMultiPiece = mapM fromPathPiece toPathMultiPiece = map toPathPiece++-- | A function for helping generate free 'PathPiece'+-- instances for enumeration data types +-- that have derived 'Read' and 'Show' instances.+-- Intended to be used like this:+--+-- > data MyData = Foo | Bar | Baz+-- > deriving (Read,Show)+-- > instance PathPiece MyData where+-- > fromPathPiece = readFromPathPiece+-- > toPathPiece = showToPathPiece+--+-- Since 0.2.1. +readFromPathPiece :: Read s => S.Text -> Maybe s+readFromPathPiece = readMaybe . S.unpack++-- | See the documentation for 'readFromPathPiece'.+--+-- Since 0.2.1. +showToPathPiece :: Show s => s -> S.Text+showToPathPiece = S.pack . show {-# DEPRECATED toSinglePiece "Use toPathPiece instead of toSinglePiece" #-} toSinglePiece :: PathPiece p => p -> S.Text
path-pieces.cabal view
@@ -1,5 +1,5 @@ name: path-pieces-version: 0.2.0+version: 0.2.1 license: BSD3 license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>