natefaubion / purescript-routing-duplex

Unified parsing and printing for routes in PureScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make `RouteState` polymorphic

paluh opened this issue · comments

commented

Hi,

Thanks for building this lib. I really love it!

I'm writing a basic full hybrid application prototype and I wanted to build and parse the whole requests using this library (in such a case I probably can share the router dispatch logic and provide different interpreters for the backend and the frontent - a kind of "RPC" and I woudn't need any servant like type level machinery for my app).
It would be probably much easier for me to extend this lib if the RouteState was polymorphic:

type RouteState r =
  { segments :: Array String
  , params :: RouteParams
  , hash :: String
  | r
  }

For sure I can try to do this by providing lifting of the current RouteDuplex values into my extended one but it won't be as nice as this polymorphic approach I think.

Is this complication worth addition? What do you think?

commented

I should prototype more on my own before opening this issue. I'm closing it for now.

commented

It seems that when I try to move to the polymorphic version of RouteState I've problems with all the generic helpers which use Record based API (like sum etc.).

@natefaubion sorry for bothering you directly but would you be so kind and tell me what do you think:

Does this attempt to make RouteState polymorphic make any sens to you? Do you think it is feasible or should I just go and make a hard fork of the lib and define my monomorphic extended RouteState and use it in my project?

I think adding polymorphic parser state is outside the scope of this project. I think it already has a pretty significant weirdness budget with all the type-level cuteness, and it would add another layer for something that is not the primary intended use case. That's not to say it isn't valuable, but if I wanted to make it more extensible, I'd probably try to formulate it in terms of something like purescript-codec.

commented

Thanks a lot for the quick answer!

commented

@natefaubion so I ended up coping nearly the whole lib into my new project. I hope that LICENSE and credits section inform clearly enough that you are the main author of these pieces :-)