-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add doctype encoder #53
Conversation
If I remember correctly, are you relatively new to Scala? This works based on "implicits" (also known as "contextual abstractions" in Scala 3). The http4s documentations probably assumes some familiarity with the concept. Long story short, it is able to choose the function automatically by matching the types. But this is a Scala technique—not specific to http4s. Regarding the duplication, if you really want to avoid it I believe that both |
I'm very fresh to Scala. I've only started learning Scala 3 maybe a month ago. This is what I am working on: https://github.com/mabasic/izradaweba
I haven't yet come to that part in the Scala 3 book :). Reading the http4s documentation feels like reading an alien language, but the code produced seems very logical.
I know that doctype implements that interface, but I'm not sure about Frag. Even if they do they don't have the render method which generates a string. https://github.com/com-lihaoyi/scalatags/search?q=Writable It would seem that only doctype extends Writable... I really don't know why doctype is not the same as Frag or ConcreteHtmlTag[String] but completely different. |
Damn. Sorry, I must have been confused. Then the duplication seems inevitable. perhaps lets just name the method differently? |
Do you have something in mind? |
scalatags/src/main/scala/org/http4s/scalatags/ScalatagsInstances.scala
Outdated
Show resolved
Hide resolved
…es.scala Co-authored-by: Arman Bilge <[email protected]>
@armanbilge I have made the suggested changes and added tests for doctype. Can we merge this and make a release :) ? P.S. Can I try to rewrite this library using Scala 3 or is there a reason why it is still on Scala 2? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice work!
P.S. Can I try to rewrite this library using Scala 3 or is there a reason why it is still on Scala 2?
Feel free to make a Scala 3 only fork of the library. The reason it is still on Scala 2 (like most other open source Scala projects) is because it is important to continue supporting users who have not yet updated to Scala 3. This will be the situation for many years.
@armanbilge As you can see there is duplicate code, but I don't currently know how to fix that ...
Fixes: #44
I'm not really happy with this code. It should work, but it seems clunky. The http4s documentation on encoders is just terrible :( Why can't I just tell http4s that if it receives this type or this type do to this. How does it even get the function which matches. So many unknowns here.