Skip to content

Commit

Permalink
Merge pull request #32 from fizruk/cdepillabout-add-form-url-encoded
Browse files Browse the repository at this point in the history
Forms
  • Loading branch information
fizruk authored Aug 31, 2016
2 parents 035ed1f + f59b5c9 commit 56c53a4
Show file tree
Hide file tree
Showing 14 changed files with 1,063 additions and 148 deletions.
1 change: 1 addition & 0 deletions .ghci
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:set -itest -isrc -optP-include -optP .stack-work/dist/x86_64-osx/Cabal-1.24.0.0/build/autogen/cabal_macros.h -optP-I -optPinclude
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/tarballs/
*.swp
.stack-work/
src/highlight.js
src/style.css
24 changes: 20 additions & 4 deletions http-api-data.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ description: Please see README.md
homepage: http://github.com/fizruk/http-api-data
category: Web
stability: unstable
cabal-version: >= 1.8
cabal-version: >= 1.10
build-type: Custom
extra-source-files:
include/overlapping-compat.h
test/*.hs
CHANGELOG.md
README.md
Expand All @@ -22,28 +23,43 @@ flag use-text-show

library
hs-source-dirs: src/
include-dirs: include/
build-depends: base >= 4.6 && < 4.10
, text >= 0.5
, bytestring
, containers
, hashable
, text >= 0.5
, time
, time-locale-compat >=0.1.1.0 && <0.2
, unordered-containers
, uri-bytestring
if flag(use-text-show)
cpp-options: -DUSE_TEXT_SHOW
build-depends: text-show >= 2
exposed-modules:
Web.HttpApiData
Web.HttpApiData.Internal
Web.FormUrlEncoded
Web.Internal.FormUrlEncoded
Web.Internal.HttpApiData
ghc-options: -Wall
default-language: Haskell2010

test-suite spec
type: exitcode-stdio-1.0
main-is: Spec.hs
hs-source-dirs: test/
other-modules:
Web.Internal.FormUrlEncodedSpec
Web.Internal.HttpApiDataSpec
Web.Internal.TestInstances
hs-source-dirs: test
ghc-options: -Wall
default-language: Haskell2010
build-depends: HUnit
, hspec >= 1.3
, base >= 4 && < 5
, bytestring
, QuickCheck
, unordered-containers
, http-api-data
, text
, time
Expand Down
8 changes: 8 additions & 0 deletions include/overlapping-compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#if __GLASGOW_HASKELL__ >= 710
#define OVERLAPPABLE_ {-# OVERLAPPABLE #-}
#define OVERLAPPING_ {-# OVERLAPPING #-}
#else
{-# LANGUAGE OverlappingInstances #-}
#define OVERLAPPABLE_
#define OVERLAPPING_
#endif
41 changes: 41 additions & 0 deletions src/Web/FormUrlEncoded.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
-- |
-- Convert Haskell values to and from @application/xxx-form-urlencoded@ format.
module Web.FormUrlEncoded (
-- * Classes
ToForm (..),
FromForm (..),

-- ** Keys for 'Form' entries
ToFormKey(..),
FromFormKey(..),

-- * Encoding and decoding @'Form'@s
urlEncodeAsForm,
urlDecodeAsForm,

urlEncodeForm,
urlDecodeForm,

-- * 'Generic's
genericToForm,
genericFromForm,

-- ** Encoding options
FormOptions(..),
defaultFormOptions,

-- * Helpers
toEntriesByKey,
fromEntriesByKey,

lookupAll,
lookupMaybe,
lookupUnique,

parseAll,
parseMaybe,
parseUnique,
) where

import Web.Internal.FormUrlEncoded

4 changes: 2 additions & 2 deletions src/Web/HttpApiData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module Web.HttpApiData (
readTextData,
) where

import Web.HttpApiData.Internal
import Web.Internal.HttpApiData

-- $setup
--
Expand Down Expand Up @@ -69,7 +69,7 @@ import Web.HttpApiData.Internal
-- "45.2"
-- >>> parseQueryParam "452" :: Either Text Int
-- Right 452
-- >>> toQueryParams [1..5]
-- >>> toQueryParams [1..5] :: [Text]
-- ["1","2","3","4","5"]
-- >>> parseQueryParams ["127", "255"] :: Either Text [Int8]
-- Left "out of bounds: `255' (should be between -128 and 127)"
Expand Down
Loading

0 comments on commit 56c53a4

Please sign in to comment.