Replies: 7 comments 55 replies
-
I think there was a wide consensus that this was a good idea.
|
Beta Was this translation helpful? Give feedback.
-
To the 😕ers, it's not so much that Also, put a |
Beta Was this translation helpful? Give feedback.
-
I think this would be a great improvement, and as a related matter, middlewares being "just Kleisli" is also problematic - an exception deep down in the stack won't be processed "on the way out" by middlewares above it, as they only deal with responses, but this is both surprising and difficult to deal with. If routes (and middlewares) could only produce requests/responses and not be allowed to throw unhandled exceptions like that it would be a lot more intuitive and less error prone than what we have today. That's in addition the very scary looking type errors that pop out when new team members change something incorrectly, of course. |
Beta Was this translation helpful? Give feedback.
-
Related to this, I think most folks agree that a good way to flat the learning curve of the typelevel ecosystem is using |
Beta Was this translation helpful? Give feedback.
-
Looking at #6740, I am in agreement with dealiasing HttpApp and HttpRoutes, but in disagreement with the details, particularly the hardcoding of Request as the input and Response as the output. Being able to compose and as plain functions is a major part of http4s' appeal. When we hardcode the inputs and outputs, we:
I think Kleisli has been unfairly maligned, particularly by demonstrably false performance claims, but I concede that it is unduly prominent in the API. The bare minimum a server needs in 0.23 is
|
Beta Was this translation helpful? Give feedback.
-
History lesson, since a lot of old ideas are new again in this thread:
|
Beta Was this translation helpful? Give feedback.
-
I like this – especially because I loathe type aliases. It always seemed like a leaky abstraction to me. Is there even a viable solution for newtypes that works across scala 2/3? It might even make sense to introduce a friendly name for <+> now with the added context? |
Beta Was this translation helpful? Give feedback.
-
There have been several discussions on Gitter and other venues around
HttpRoutes
/HttpApp
. One argument that keeps coming back when newcomers see http4s is that these types are difficult to understand when you dealias them - mostly everyone using Scala understands functions andOption
, but not everyone coming to the language will know whatKleisli
andOptionT
is.I think this complexity isn't worth the benefit - composing routes with
<+>
could be done if it was an operator defined directly on some concrete type, middleware could wrap a function intoKleisli
to make transformations more easily, and internals supposedly don't rely on this shape either.For that reason, I would like to bring back an idea suggested by other people in the past:
We already have
HttpApp.of
/HttpRoutes.of
which are really good for avoiding the complexity at definition site, but the moment someone sees a type mismatch (e.g.bindHttpApp(httpRoutes)
), they see the monad transformer gang. A change like this would make it possible, while keeping existing functionality (assumingHttpRoutes.apply
exists anda => HttpRoutes(a.run)
is identity).I would love to see this in 1.0 and I'd be happy to work on this, if we have consensus that it's a good idea.
I'll dig up the recent discussion later, unless someone beats me to it. :)
Beta Was this translation helpful? Give feedback.
All reactions