val cookies = Map("sessionid" -> "1234567")
val headers = Map("Content-Type" -> "application/javascript")
setCookies(headers) {
setHeaders(headers) {
complete { obj }
}
}
With Scala's "make everything a different type" approach, that's a compile error - setCookies will expect a List[Cookie], not a List[HttpHeader].Those of us living in Scalaland are not as smart as the Clojure guys. We make mistakes sometimes and find it handy when the compiler yells at us.
case class MyNewType(x: String) extends AnyVal
What do you want to do that that isn't sufficient for?You can also use tagged types:
http://eed3si9n.com/learning-scalaz/Tagged+type.html
But most of the methods will untag the type. I.e., ("foo" @@ ValidJsonString).substring(3,7) will be a String, not a String @@ ValidJsonString.
http://etorreborre.blogspot.co.uk/2011/11/practical-uses-for...
Scalaz implements this, so you can use it straight away. We use it mostly to control implicit selection.
1st they don't propagate, call a function on the tagged type and it returns the underlying type.
2nd they aren't type safe against the tagged type, so you can pass tagged types into functions that take the underlying type by default.
3rd in practice my code with tagged types ends up having lots of boilerplate and/or magic code that is hard to understand.
4th there are some pretty heinous compiler bugs that you will encounter with tagged types.
val x = 1.0 @@ Kilograms
val y = x*x
y is not a Double @@ Kilograms.http://docs.scala-lang.org/overviews/core/value-classes.html
Its not what is possible, but what is. And the fact is that all the Clojure web framework and library's use the same data structure even if the underlying implementation is different. See how ring uses much of the same thing as the pedestal service.