@@ -211,7 +211,8 @@ instance IsList Form where
211-- instance 'ToForm' Person
211-- instance 'ToForm' Person
214+-- The default implementation of 'toForm' is 'genericToForm'.
214−-- The default implementation will use 'toQueryParam' for each field's value.
215+-- It only works for records and it will use 'toQueryParam' for each field's value.
215class ToForm a where
216class ToForm a where
216 -- | Convert a value into 'Form'.
217 -- | Convert a value into 'Form'.
217 toForm :: a -> Form
218 toForm :: a -> Form
@@ -243,6 +244,15 @@ data Proxy3 a b c = Proxy3
244-- | A 'Generic'-based implementation of 'toForm'.
245-- | A 'Generic'-based implementation of 'toForm'.
245-- This is used as a default implementation in 'ToForm'.
246-- This is used as a default implementation in 'ToForm'.
248+-- Note that this only works for records (i.e. product data types with named fields):
251+-- data Person = Person
254+-- } deriving ('Generic')
246genericToForm :: (Generic a, GToForm (Rep a)) => a -> Form
256genericToForm :: (Generic a, GToForm (Rep a)) => a -> Form
247genericToForm = gToForm . from
257genericToForm = gToForm . from
@@ -296,7 +306,8 @@ instance (Selector s, ToHttpApiData c) => GToForm (M1 S s (K1 i c)) where
296-- instance 'FromForm' Person
306-- instance 'FromForm' Person
309+-- The default implementation of 'fromForm' is 'genericFromForm'.
299−-- The default implementation will use 'parseQueryParam' for each field's value.
310+-- It only works for records and it will use 'parseQueryParam' for each field's value.
300class FromForm a where
311class FromForm a where
301 -- | Parse 'Form' into a value.
312 -- | Parse 'Form' into a value.
302 fromForm :: Form -> Either Text a
313 fromForm :: Form -> Either Text a
@@ -329,6 +340,15 @@ toEntriesByKey = traverse parseGroup . HashMap.toList . unForm
330-- | A 'Generic'-based implementation of 'fromForm'.
341-- | A 'Generic'-based implementation of 'fromForm'.
331-- This is used as a default implementation in 'FromForm'.
342-- This is used as a default implementation in 'FromForm'.
344+-- Note that this only works for records (i.e. product data types with named fields):
347+-- data Person = Person
350+-- } deriving ('Generic')
332genericFromForm :: (Generic a, GFromForm (Rep a))
352genericFromForm :: (Generic a, GFromForm (Rep a))
333 => Form -> Either Text a
353 => Form -> Either Text a
334genericFromForm f = to <$> gFromForm f
354genericFromForm f = to <$> gFromForm f