Replies: 5 comments 8 replies
-
This sounds like it would require rethinking the module structure as well, so that the |
Beta Was this translation helpful? Give feedback.
-
Because an simple up-vote doesn't express how much I would love something like this, I'll express it in words. This was my experience:
import cats.effect._, org.http4s._, org.http4s.dsl.io._
// import cats.effect.unsafe.IORuntime I'll leave this one out because in scala-cli I could use IOApp
import cats.syntax.all._
import com.comcast.ip4s._
import org.http4s.ember.server._
import org.http4s.implicits._
import org.http4s.server.Router
import scala.concurrent.duration._ The problem is the docs don't explain these imports, and my first instinct is what is all these things for? Isn't this all too much? What do they all do? The reader should just "assume" these things, but personally I got confused, because it feels like I need to know what all these namespaces contain, but I just want my server to print Hello World 🥲 !
import cats._
import cats.effect._
import cats.implicits._
import org.http4s.circe._
import org.http4s._
import io.circe.generic.auto._
import io.circe.syntax._
import org.http4s.dsl._
import org.http4s.dsl.impl._
import org.http4s.headers._
import org.http4s.implicits._
import org.http4s.server._ Oh my...well atleast these are all the exports I need for the tutorial itself, so it isn't bad. But it was another gasp moment. But even after that initial stumble, it seems that a surprising amount of problems I had were solved by some sort of Editor tooling help a lot with missing imports, but in certain libraries(like Cask, Express, http in Go), it's really really easy to just get started. For example in Giraffe(think http4s for F#): open System
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
open Microsoft.Extensions.Hosting
open Microsoft.Extensions.Logging
open Microsoft.Extensions.DependencyInjection
open Giraffe Even though it might not be easier than a Go or JS http server, it still is less intimidating than http4s, for a beginner. So my problem with imports might itself be more a docs problem than the amount of imports, and I could even make a snippet that just expands to the "standard" imports...but good/nice defaults matter imho and I think http4s can be nicer in that way. |
Beta Was this translation helpful? Give feedback.
-
I just floated a (crazy?) idea in #7053 (comment) that we should collapse core+server+client+ember into a single One compelling motivation for this would be so that you can do something like |
Beta Was this translation helpful? Give feedback.
-
Don't forget |
Beta Was this translation helpful? Give feedback.
-
Are we just waiting at this point for someone to go ahead and open a strawman PR for this? Another thing that I was thinking about was to alias relevant ip4s types into the http4s package, as it feels weird and surprising having |
Beta Was this translation helpful? Give feedback.
-
Historically, the weathered scrolls which held the account of what http4s imports one needs have been passed down generation after generation. Elders gathered at the town square and chanted the sacred words:
But centuries have passed, scrolls were replaced by screens, and the chance of remembering which exact imports do what acted as the evolutionary barrier, killing the weakest.
For Http4s 1.0.0 at least (ideally much earlier) it would be good to offer the users a simplified
org.http4s.all.*
import.Good for scripting, good for getting started docs, hell, good for experienced people who forget where exactly GET and Root are.
Or move all that into the
import org.http4s.dsl.io
.Let's discuss!
Beta Was this translation helpful? Give feedback.
All reactions