git.iko.soy/typeable/http-api-data
on master help sign in
Allow negative integers yesodweb/yesod#613
8fe4152Michael Snoyman
Web/PathPieces.hs+3−3
@@ -33,21 +33,21 @@ instance PathPiece L.Text where
33
33
34instance PathPiece Integer where
34instance PathPiece Integer where
35 fromPathPiece s =
35 fromPathPiece s =
36− case Data.Text.Read.decimal s of
36+ case Data.Text.Read.signed Data.Text.Read.decimal s of
37 Right (i, _) -> Just i
37 Right (i, _) -> Just i
38 Left _ -> Nothing
38 Left _ -> Nothing
39 toPathPiece = S.pack . show
39 toPathPiece = S.pack . show
40
40
41instance PathPiece Int where
41instance PathPiece Int where
42 fromPathPiece s =
42 fromPathPiece s =
43− case Data.Text.Read.decimal s of
43+ case Data.Text.Read.signed Data.Text.Read.decimal s of
44 Right (i, _) -> Just i
44 Right (i, _) -> Just i
45 Left _ -> Nothing
45 Left _ -> Nothing
46 toPathPiece = S.pack . show
46 toPathPiece = S.pack . show
47
47
48instance PathPiece Int64 where
48instance PathPiece Int64 where
49 fromPathPiece s =
49 fromPathPiece s =
50− case Data.Text.Read.decimal s of
50+ case Data.Text.Read.signed Data.Text.Read.decimal s of
51 Right (i, _) -> Just i
51 Right (i, _) -> Just i
52 Left _ -> Nothing
52 Left _ -> Nothing
53 toPathPiece = S.pack . show
53 toPathPiece = S.pack . show
path-pieces.cabal−1
@@ -26,7 +26,6 @@ test-suite test
26 ghc-options: -Wall
26 ghc-options: -Wall
27 build-depends: HUnit
27 build-depends: HUnit
28 , hspec >= 1.3
28 , hspec >= 1.3
29− , file-location >= 0.4 && < 0.5
30 , base >= 4 && < 5
29 , base >= 4 && < 5
31 , QuickCheck
30 , QuickCheck
32 , path-pieces
31 , path-pieces
test/main.hs+1−1
@@ -34,7 +34,7 @@ spec = do
34
34
35 prop "toPathPiece <=> fromPathPiece String" $ \(p::Int) ->
35 prop "toPathPiece <=> fromPathPiece String" $ \(p::Int) ->
36 case (fromPathPiece . toPathPiece) p of
36 case (fromPathPiece . toPathPiece) p of
37− Nothing -> p < 0
37+ Nothing -> False
38 Just pConverted -> p == pConverted
38 Just pConverted -> p == pConverted
39
39
40 describe "PathMultiPiece" $ do
40 describe "PathMultiPiece" $ do