git.iko.soy/typeable/http-api-data
on master help sign in
Move Form-related stuff to Web.FormUrlEncoded
4233ec9Nickolay Kudasov
http-api-data.cabal+6−5
@@ -36,8 +36,9 @@ library
36 build-depends: text-show >= 2
36 build-depends: text-show >= 2
37 exposed-modules:
37 exposed-modules:
38 Web.HttpApiData
38 Web.HttpApiData
39+ Web.FormUrlEncoded
39− Web.HttpApiData.Internal.FormUrlEncoded
40+ Web.Internal.FormUrlEncoded
40− Web.HttpApiData.Internal.HttpApiData
41+ Web.Internal.HttpApiData
41 ghc-options: -Wall
42 ghc-options: -Wall
42 default-language: Haskell2010
43 default-language: Haskell2010
43
44
@@ -45,9 +46,9 @@ test-suite spec
45 type: exitcode-stdio-1.0
46 type: exitcode-stdio-1.0
46 main-is: Spec.hs
47 main-is: Spec.hs
47 other-modules:
48 other-modules:
48− Web.HttpApiData.Internal.FormUrlEncodedSpec
49+ Web.Internal.FormUrlEncodedSpec
49− Web.HttpApiData.Internal.HttpApiDataSpec
50+ Web.Internal.HttpApiDataSpec
50− Web.HttpApiData.Internal.TestInstances
51+ Web.Internal.TestInstances
51 hs-source-dirs: test
52 hs-source-dirs: test
52 ghc-options: -Wall
53 ghc-options: -Wall
53 default-language: Haskell2010
54 default-language: Haskell2010
src/Web/FormUrlEncoded.hsnew file+17
@@ -0,0 +1,17 @@
1+-- |
2+-- Convert Haskell values to and from @application/xxx-form-urlencoded@ format.
3+module Web.FormUrlEncoded (
4+ -- * Classes
5+ ToForm (..),
6+ FromForm (..),
7+
8+ -- * Encoding and decoding @'Form'@s
9+ encodeAsForm,
10+ decodeAsForm,
11+
12+ encodeForm,
13+ decodeForm,
14+) where
15+
16+import Web.Internal.FormUrlEncoded
17+
src/Web/HttpApiData.hs+1−11
@@ -8,8 +8,6 @@ module Web.HttpApiData (
8 -- * Classes
8 -- * Classes
9 ToHttpApiData (..),
9 ToHttpApiData (..),
10 FromHttpApiData (..),
10 FromHttpApiData (..),
11− ToForm (..),
12− FromForm (..),
13
11
14 -- * @'Maybe'@ parsers
12 -- * @'Maybe'@ parsers
15 parseUrlPieceMaybe,
13 parseUrlPieceMaybe,
@@ -37,20 +35,12 @@ module Web.HttpApiData (
37 parseBoundedEnumOfI,
35 parseBoundedEnumOfI,
38 parseBoundedTextData,
36 parseBoundedTextData,
39
37
40− -- * Encoding and decoding @'Form'@s
41− encodeAsForm,
42− decodeAsForm,
43−
44− encodeForm,
45− decodeForm,
46−
47 -- * Other helpers
38 -- * Other helpers
48 showTextData,
39 showTextData,
49 readTextData,
40 readTextData,
50) where
41) where
51
42
52−import Web.HttpApiData.Internal.FormUrlEncoded
53−import Web.HttpApiData.Internal.HttpApiData
43+import Web.Internal.HttpApiData
54
44
55-- $setup
45-- $setup
56--
46--
src/Web/HttpApiData/Internal/FormUrlEncoded.hs → src/Web/Internal/FormUrlEncoded.hsrenamed+2−2
@@ -10,7 +10,7 @@
10{-# LANGUAGE ScopedTypeVariables #-}
10{-# LANGUAGE ScopedTypeVariables #-}
11{-# LANGUAGE TypeFamilies #-}
11{-# LANGUAGE TypeFamilies #-}
12{-# LANGUAGE TypeOperators #-}
12{-# LANGUAGE TypeOperators #-}
13−module Web.HttpApiData.Internal.FormUrlEncoded where
13+module Web.Internal.FormUrlEncoded where
14
14
15#if __GLASGOW_HASKELL__ < 710
15#if __GLASGOW_HASKELL__ < 710
16import Control.Applicative
16import Control.Applicative
@@ -30,7 +30,7 @@ import GHC.Generics
30import Network.URI (escapeURIString, isUnreserved,
30import Network.URI (escapeURIString, isUnreserved,
31 unEscapeString)
31 unEscapeString)
32
32
33−import Web.HttpApiData.Internal.HttpApiData
33+import Web.Internal.HttpApiData
34
34
35-- $setup
35-- $setup
36-- >>> :set -XDeriveGeneric
36-- >>> :set -XDeriveGeneric
src/Web/HttpApiData/Internal/HttpApiData.hs → src/Web/Internal/HttpApiData.hsrenamed+1−1
@@ -7,7 +7,7 @@
7-- |
7-- |
8-- Convert Haskell values to and from HTTP API data
8-- Convert Haskell values to and from HTTP API data
9-- such as URL pieces, headers and query parameters.
9-- such as URL pieces, headers and query parameters.
10−module Web.HttpApiData.Internal.HttpApiData where
10+module Web.Internal.HttpApiData where
11
11
12#if __GLASGOW_HASKELL__ < 710
12#if __GLASGOW_HASKELL__ < 710
13import Control.Applicative
13import Control.Applicative
test/Web/HttpApiData/Internal/FormUrlEncodedSpec.hs → test/Web/Internal/FormUrlEncodedSpec.hsrenamed+4−4
@@ -1,7 +1,7 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE ScopedTypeVariables #-}
3{-# LANGUAGE ScopedTypeVariables #-}
4−module Web.HttpApiData.Internal.FormUrlEncodedSpec (spec) where
4+module Web.Internal.FormUrlEncodedSpec (spec) where
5
5
6#if __GLASGOW_HASKELL__ < 710
6#if __GLASGOW_HASKELL__ < 710
7import Control.Applicative
7import Control.Applicative
@@ -14,9 +14,9 @@ import Data.Text (Text, unpack)
14import Test.Hspec
14import Test.Hspec
15import Test.QuickCheck
15import Test.QuickCheck
16
16
17−import Web.HttpApiData.Internal.FormUrlEncoded
17+import Web.Internal.FormUrlEncoded
18−import Web.HttpApiData.Internal.HttpApiData
18+import Web.Internal.HttpApiData
19−import Web.HttpApiData.Internal.TestInstances
19+import Web.Internal.TestInstances
20
20
21spec :: Spec
21spec :: Spec
22spec = do
22spec = do
test/Web/HttpApiData/Internal/HttpApiDataSpec.hs → test/Web/Internal/HttpApiDataSpec.hsrenamed+3−3
@@ -1,5 +1,5 @@
1{-# Language ScopedTypeVariables #-}
1{-# Language ScopedTypeVariables #-}
2−module Web.HttpApiData.Internal.HttpApiDataSpec (spec) where
2+module Web.Internal.HttpApiDataSpec (spec) where
3
3
4import Data.Int
4import Data.Int
5import Data.Word
5import Data.Word
@@ -14,9 +14,9 @@ import Test.Hspec
14import Test.Hspec.QuickCheck(prop)
14import Test.Hspec.QuickCheck(prop)
15import Test.QuickCheck
15import Test.QuickCheck
16
16
17−import Web.HttpApiData.Internal.HttpApiData
17+import Web.Internal.HttpApiData
18
18
19−import Web.HttpApiData.Internal.TestInstances
19+import Web.Internal.TestInstances
20
20
21
21
22(<=>) :: Eq a => (a -> b) -> (b -> Either T.Text a) -> a -> Bool
22(<=>) :: Eq a => (a -> b) -> (b -> Either T.Text a) -> a -> Bool
test/Web/HttpApiData/Internal/TestInstances.hs → test/Web/Internal/TestInstances.hsrenamed+3−3
@@ -2,7 +2,7 @@
2{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE ScopedTypeVariables #-}
3{-# LANGUAGE ScopedTypeVariables #-}
4{-# OPTIONS_GHC -fno-warn-orphans #-}
4{-# OPTIONS_GHC -fno-warn-orphans #-}
5−module Web.HttpApiData.Internal.TestInstances
5+module Web.Internal.TestInstances
6 ( RandomCase(..)
6 ( RandomCase(..)
7 , SimpleRec(..)
7 , SimpleRec(..)
8 , SimpleSumRec(..)
8 , SimpleSumRec(..)
@@ -22,8 +22,8 @@ import GHC.Generics
22
22
23import Test.QuickCheck
23import Test.QuickCheck
24
24
25−import Web.HttpApiData.Internal.FormUrlEncoded
25+import Web.Internal.FormUrlEncoded
26−import Web.HttpApiData.Internal.HttpApiData
26+import Web.Internal.HttpApiData
27
27
28instance Arbitrary T.Text where
28instance Arbitrary T.Text where
29 arbitrary = T.pack <$> arbitrary
29 arbitrary = T.pack <$> arbitrary