git.iko.soy/typeable/http-api-data
on master help sign in
Add Day (yesodweb/yesod#320)
cd5d554Michael Snoyman
Web/PathPieces.hs+7
@@ -13,6 +13,7 @@ import Data.Int (Int64)
13import qualified Data.Text as S
13import qualified Data.Text as S
14import qualified Data.Text.Lazy as L
14import qualified Data.Text.Lazy as L
15import qualified Data.Text.Read
15import qualified Data.Text.Read
16+import Data.Time (Day)
16
17
17class PathPiece s where
18class PathPiece s where
18 fromPathPiece :: S.Text -> Maybe s
19 fromPathPiece :: S.Text -> Maybe s
@@ -51,6 +52,12 @@ instance PathPiece Int64 where
51 Left _ -> Nothing
52 Left _ -> Nothing
52 toPathPiece = S.pack . show
53 toPathPiece = S.pack . show
53
54
55+instance PathPiece Day where
56+ fromPathPiece t =
57+ case reads $ S.unpack t of
58+ [(a,"")] -> Just a
59+ _ -> Nothing
60+ toPathPiece = S.pack . show
54
61
55class PathMultiPiece s where
62class PathMultiPiece s where
56 fromPathMultiPiece :: [S.Text] -> Maybe s
63 fromPathMultiPiece :: [S.Text] -> Maybe s
path-pieces.cabal+2−1
@@ -1,5 +1,5 @@
1name: path-pieces
1name: path-pieces
2−version: 0.1.0
2+version: 0.1.1
3license: BSD3
3license: BSD3
4license-file: LICENSE
4license-file: LICENSE
5author: Michael Snoyman <michael@snoyman.com>
5author: Michael Snoyman <michael@snoyman.com>
@@ -14,6 +14,7 @@ homepage: http://github.com/snoyberg/path-pieces
14library
14library
15 build-depends: base >= 4 && < 5
15 build-depends: base >= 4 && < 5
16 , text >= 0.5 && < 0.12
16 , text >= 0.5 && < 0.12
17+ , time
17 exposed-modules: Web.PathPieces
18 exposed-modules: Web.PathPieces
18 ghc-options: -Wall
19 ghc-options: -Wall
19
20