Enumerating keys in a querystring

I’m using this package to parse query strings:

I’m able to parse a query string pretty easily. What I’m struggling to do is enumerate the keys of the query string parameters. The package parses the query string into a dictionary. Here’s the constructor of QueryString:

type QueryString
    = QueryString (Dict String (List String))

The type just wraps a dictionary. I tried:

Dict.keys qs

Where qs is the parsed query string. This doesn’t work. I get an error message telling me that I passed the wrong type to Dict.keys.

Any idea how to get at the dictionary that QueryString contains?

Thanks in advance,
Eric

You said it right, just wraps a dictionary, so you need to unwrap that Dict first and then pass it to the Dict.keys.

case qs of
  QueryString qs_ ->
    Dict.keys qs_

Tip: since QueryString has only construct you can pattern match that using a function in this way:

queryStringKeys (QueryString qs) = 
  Dict.keys qs

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.