types of strings

hi,

i regularly encounter situations where strings are used. for example it
might be an url. or a resource key. or a string that is supposed to be
sent to a brower and has to be escaped.
and i regularly see errors caused by the fact that you cannot ask a
string if it has already been resolved (if it's a resource key) or
escaped, or if it is a relative or absolute url. if it even is one.

in java, i try to make this a bit safer by creating simple wrappers like
"class ResourceKey(val key:String)" to make sure i don't accidently mix
them up. is there a way to achieve this in scala without wrapper
classes? can i somehow (mis)use abstract types for this?

basically i want to say :

type AbsoluteUrl = ???
def iAmAbsolutelySureThisIsAnAbsoluteUrl(url:String) =
url.asInstanceOf[AbsoluteUrl]

Copyright © 2013 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland