Skip to content

RFC: embedded string interpolationsΒ #44

@danicheg

Description

@danicheg

This issue is a follow-up from http4s/http4s#3433.
I've struggled with this a bit and think it's quite problematic to embed string interpolations to uri"" and path"" of http4s (actually, it's so for every interpolated macros based on literally):

  1. At the moment, compilation fails if invalid strings have been passed (underlying validate is calling at compile time).
  2. Say
val foo = "/foo/bar"
val someuri = uri"https://example.com$foo"

means that we should check the value of foo at the runtime (generally, foo could be some computation, not a constant value). So bringing embedded string interpolations means we should proceed with runtime values at compile time (because of 1). I'm not that much a Scala macros astronaut, but am feeling it's probably impossible.

UPD: speaking more accurately, compile-time checking is only possible for the literal part of the passed string.

If anyone has insights about that, please share them here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions