Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion src/Web/Internal/FormUrlEncoded.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import Data.Time.Compat (Day, LocalTime, NominalDiffTime,
UTCTime, ZonedTime)
import Data.Time.Calendar.Month.Compat (Month)
import Data.Time.Calendar.Quarter.Compat (Quarter, QuarterOfYear (..))
import Data.Void (Void)
import Data.Void (Void, absurd)
import Data.Word (Word16, Word32, Word64, Word8)
import GHC.Exts (Constraint, IsList (..))
import GHC.Generics
Expand Down Expand Up @@ -267,6 +267,10 @@ class ToForm a where

instance ToForm Form where toForm = id

instance ToForm Void where toForm = absurd

instance ToForm () where toForm _ = Form HashMap.empty

instance (ToFormKey k, ToHttpApiData v) => ToForm [(k, v)] where
toForm = fromList . map (toFormKey *** toQueryParam)

Expand Down Expand Up @@ -413,6 +417,10 @@ class FromForm a where

instance FromForm Form where fromForm = pure

instance FromForm Void where fromForm _ = Left "fromForm: Void"

instance FromForm () where fromForm _ = Right ()

-- | _NOTE:_ this conversion is unstable and may result in different key order (but not values).
instance (FromFormKey k, FromHttpApiData v) => FromForm [(k, v)] where
fromForm = fmap (concatMap (\(k, vs) -> map ((,) k) vs)) . toEntriesByKey
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-12.10
resolver: lts-23.3
packages:
- '.'
flags:
Expand Down