natpryce
12/01/2025, 10:36 AMval Path.bob by lazyOf(Path.value(Bob).of("bob"))
Then using them in routes can get quite verbose…
"/${Path.alice}/${Path.bob}/${Path.carol}" bind ...
But the following inline function lets you refer to them without the Path. prefix and therefore without curly braces:
inline operator fun Path.invoke(mkPath: Path.() -> String) = mkPath()
Now I can write bindings like…
Path { "/$alice/$bob/$carol" } bind ...dave
12/01/2025, 7:24 PMval Path.foo by <http://Path.int|Path.int>()
assertThat(Path { "bar/${foo}" }, equalTo("bar/{foo}"))Andrew O'Hara
12/05/2025, 6:28 PMlazy delegate is far more efficient than what I've previously done to avoid polluting the class's companion object or global namespace. I know the JVM is very good at collecting recently created immutable garbage, but the instantiations must add up at scale.
val DeviceId.Companion.pathLens get() = Path.value(DeviceId).of("device_id")natpryce
12/06/2025, 9:44 AM