Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forms #32

Merged
merged 43 commits into from
Aug 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1b468b0
Move FormUrlEncoded from servant.
jkarni Jan 21, 2016
0e7f261
Fix test for `decodeForm . encodeForm`
cdepillabout Aug 24, 2016
ac72f9e
Fix PR so it works on ghc-7.8.
cdepillabout Aug 24, 2016
acc2cd4
Remove dependency on string-conversions package.
cdepillabout Aug 25, 2016
97f200f
Replace uses for toUrlPiece and parseUrlPiece with toQueryParam and p…
cdepillabout Aug 25, 2016
dd1baa5
Change uses of String to Text.
cdepillabout Aug 26, 2016
8ab1a1f
Add comments and doctests to the FormUrlEncoded module.
cdepillabout Aug 26, 2016
6487f48
Add two convenience functions for encoding / decoding a ByteString di…
cdepillabout Aug 26, 2016
fb08da7
Rephrase documentation and amend some examples for FormUrlEncoded
fizruk Aug 29, 2016
6ab8a56
Use a custom Show instanse for Form (like Map has)
fizruk Aug 29, 2016
236c59a
Rename encode/decodeWith*From to encode/decodeAsForm
fizruk Aug 29, 2016
7c3d63b
Ignore stack haddock's output to src/
fizruk Aug 29, 2016
4233ec9
Move Form-related stuff to Web.FormUrlEncoded
fizruk Aug 29, 2016
9b7a61d
Simplify To/FromForm instances for lists
fizruk Aug 29, 2016
6e97168
Remove utf8-string dependency
fizruk Aug 29, 2016
f2a7554
Refactor decodeForm
fizruk Aug 29, 2016
28713e6
Remove mtl dependency, simplify GToForm and GFromForm
fizruk Aug 29, 2016
765249b
Add test case for empty form data
fizruk Aug 29, 2016
d04cfba
Refactor qualified names
fizruk Aug 29, 2016
5322053
Allow duplicate keys in Form
fizruk Aug 29, 2016
3d6065a
Add FormKey classes
fizruk Aug 30, 2016
a9976c2
Generalize ToForm/FromForm instances
fizruk Aug 30, 2016
6cd7a03
Add ToForm/FormForm instances for IntMap and HashMap
fizruk Aug 30, 2016
70060ee
Add helpers for FromForm instances
fizruk Aug 30, 2016
0456604
Change Form's internal representation to HashMap
fizruk Aug 30, 2016
550df9a
Export Generic-based toForm and fromForm
fizruk Aug 30, 2016
173ef33
Fix Travis builds for GHC 7
fizruk Aug 30, 2016
02fadd3
Rename encode/decode to urlEncode/urlDecode
fizruk Aug 30, 2016
ea020ae
Use uri-bytestring for a more efficient url-encoding and decoding
fizruk Aug 30, 2016
5a448b3
Remove Generic support for sum types
fizruk Aug 30, 2016
e9c728b
Fix GHC 7.8 builds
fizruk Aug 30, 2016
d944721
Add instances for Natural (close #33)
fizruk Aug 30, 2016
fa05cca
Rename lookupKey -> lookupAll, improve docs a bit
fizruk Aug 30, 2016
3158b55
Add notes that Generic-based implementation only works for records
fizruk Aug 30, 2016
bea3afe
Add nice type error for when ToForm/FromForm is derived for sum type
fizruk Aug 30, 2016
7a7b274
Add basic FormOptions
fizruk Aug 30, 2016
57c0a23
Fix unticked promoted constructors warning
fizruk Aug 30, 2016
4bc8d3e
Treat Maybes and lists specially when deriving Generic instances
fizruk Aug 31, 2016
9cb90d5
Fix GHC 7 builds
fizruk Aug 31, 2016
2df7799
Re-export FormOptions
fizruk Aug 31, 2016
e613d05
Add an example for non-default FormOptions
fizruk Aug 31, 2016
de9fe0f
Enable ConstraintKinds and fix typo for GHC 7.8
fizruk Aug 31, 2016
f59b5c9
Add more docs explaining special roles of Maybe and lists
fizruk Aug 31, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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