Skip to content
This repository was archived by the owner on Feb 7, 2026. It is now read-only.
This repository was archived by the owner on Feb 7, 2026. It is now read-only.

Submitting URL encoded array of structured arguments. #89

Description

@reygoch

This might be slightly related to #62.

Let's say that I have these data types:

data Something = Something
    { field01 :: Text
    , field02 :: Text
    }

data StepInstruction = StepInstruction
    { id :: Int
    , order :: Int
    , description :: Text
    }

data Recipe = Recipe
    { id :: Int
    , name :: Text
    , something :: Something
    , instructions :: [StepInstruction]
    }

In PHP I could easily submit a form with such data type and get it back in the form of a nested array. Convention for submitting Recipe is as follows:

?id=0
&name=Recipe01

&instructions[0][id]=0
&instructions[0][order]=1
&instructions[0][description]=somedescription

&instructions[1][id]=1
&instructions[1][order]=2
&instructions[1][description]=someotherdescription

Currently Query flat and I'd have to do additional parsing on the argument names to get an array of structured arguments.

I'm not sure if this is a standard, but I've also seen the same convention in C#/MVC so I think it would be a good idea to support such feature, because I might want to add repeating "sub forms" to my main form that should be contained in array, and currently there is no good way to do that from what I can see.

Here is also an example of a form that might submit such query:

<form>
    <input type="hidden" name="id">
    <input type="text" name="name">

    <input type="text" name="something[field01]">
    <input type="text" name="something[field02]">

    <div>
        <input type="hidden" name="instructions[0][id]">
        <input type="number" name="instructions[0][order]">
        <input type="text" name="instructions[0][description]">
    </div>

    <div>
        <input type="hidden" name="instructions[1][id]">
        <input type="number" name="instructions[1][order]">
        <input type="text" name="instructions[1][description]">
    </div>

    <div>
        <input type="hidden" name="instructions[2][id]">
        <input type="number" name="instructions[2][order]">
        <input type="text" name="instructions[2][description]">
    </div>
</form>

Maybe QueryItem should look something like this:

data QueryItem
    = PlainValue ByteString
    | QueryItemList [QueryItem]
    | QueryItem (ByteString, Maybe QueryItem)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions