3 ms·
As mentioned in the document, continuation passing style can at times be a little difficult to read. That being said I found a talk that using continuation pass
by anuragsoni 7y ago
As mentioned in the document, continuation passing style can at times be a little difficult to read. That being said I found a talk that using continuation passing style to provide typed routing. [1]
This won't be the most efficient way to perform routing in an application, but i found the implementation really simple to understand and the error messages for the end-user seem really clear as well. It also helps if the language used allows for embedding DSLs that are easy to read for the end-user. (could be macros in lisp/elixir, well named functions with a little sprinkling of infix operators in OCaml, Haskell etc)
A little show HN in the comments: I've been exploring this approach and others [2] for comparison, and although i've moved away from this style as I progress in learning more OCaml, it was a fun little exercise to explore a CPS based typed routing approach. [3]
[1] https://dbp.io/talks/2016/fn-continuations-haskell-meetup.pdf https://dbp.io/talks/2016/fn-continuations-haskell-meetup.pd...
[2] https://github.com/anuragsoni/routes https://github.com/anuragsoni/routes
[3] https://github.com/anuragsoni/routes/blob/0.1.0/src/routes.ml https://github.com/anuragsoni/routes/blob/0.1.0/src/routes.m...
- bjoli 7y agoWith support for first class (preferably delimited) continuations this is not a problem. I have used scheme and racket to write small web seevices, and it is really an amazing tool to have. I never had to make it scale though, but it is an amazing experience.
- zeveb 7y ago> As mentioned in the document, continuation passing style can at times be a little difficult to read. Very true. Fortunately, the CPS transform is automatic, so one could write a compiler which compiles non-CPS to CPS code. This is pretty easy in Scheme or Lisp (less so the latter, because it's a much more complex & powerful language); it's not nearly easy in other languages, but still doable.