Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to parse multiple params never completes #37

Open
joe-op opened this issue Jul 19, 2024 · 2 comments
Open

Attempting to parse multiple params never completes #37

joe-op opened this issue Jul 19, 2024 · 2 comments

Comments

@joe-op
Copy link

joe-op commented Jul 19, 2024

Example in the REPL:

import Data.Either (Either)
import Routing.Duplex (many, param, parse)
import Routing.Duplex.Parser (RouteError)

parse (many (param "hello")) "?hello=hi" :: Either RouteError (Array String)
@natefaubion
Copy link
Owner

natefaubion commented Jul 20, 2024

This is due to the dubious decision to not have param actually consume input. It just reads it, with the idea that params are more like environment variables than tokens. In order for many to terminate, it's parser must consume input. If you want to use many with params, you'd need to write a different param parser that removed the params you want to parse from the state.

@joe-op
Copy link
Author

joe-op commented Jul 26, 2024

Thanks. I've got a modified parser to work, although without the syntactic sugar related to ?.

joe-op added a commit to joe-op/purescript-routing-duplex that referenced this issue Jul 26, 2024
Named `param'` to avoid changing the behavior of `param`.
This allows matching multiple parameters in combination with `many`.

natefaubion#37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants