There isn't support for this in servant, as (as far as I know) this comma-separated format isn't really standard. You could however indeed provide a general combinator + {From,To}HttpApiData instances.
newtype CommaSep a = CommaSep [a]
instance FromHttpApiData a => FromHttpApiData (CommaSep a) where ...
instance ToHttpApiData a => ToHttpApiData (CommaSep a) where ...
where the From instance would split on each comma character and try to parse every "component" using the supplied FromHttpApiData instance for 'a'.
If you don't care about the syntax/etc, then Arian's QueryParams suggestion would probably be the simplest solution.
On Wed, Aug 14, 2019 at 11:52 AM Corentin Dupont <
[hidden email]> wrote:
Hi guys,
I hope you are doing well.
I want to parse a parameter that accepts a list of values:
I tried:
:> QueryParam "foo" [Foo]
But it complains:
No instance for (FromHttpApiData [Foo])
I could try to provide this instance of FromHttpApiData, and write a parser for parameters value list, but I was wondering if there is some kind of support already in Servant? Any example?
Thanks a lot and good vacations!
Corentin
--
--
Alp Mestanogullari
--