News for hackers. Stuff that matters.
Re:Scala – 1 Star Would Not Program Again by yummyfajitas on Tuesday January 14, 2014 @01:30PM (#7058757)
Yes, and there is a good reason why Scalaland uses types. Consider a Spray-like API using only maps:

    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.

Re:Scala – 1 Star Would Not Program Again by kasey_junk on Tuesday January 14, 2014 @01:36PM (#7058793)
This is actually a good example of something I don't like in Scala. They don't make this sort of differentiation easy enough. Adding a Haskell style newtype would be really, really useful.
Re:Scala – 1 Star Would Not Program Again by yummyfajitas on Tuesday January 14, 2014 @01:42PM (#7058837)
Scala has value types.

    case class MyNewType(x: String) extends AnyVal
What do you want to do that that isn't sufficient for?
Re:Scala – 1 Star Would Not Program Again by kasey_junk on Tuesday January 14, 2014 @02:11PM (#7059023)
AnyVal's would probably be sufficient except for the following: - Instantiation of the MyNewType happens all the time and is not obvious from inspection of the code (generics, use as another type if we implement a trait, etc). - If we want to call any of the methods on the wrapped type we have to call directly to the wrapped type violating Demeter. - Verbosity.
Re:Scala – 1 Star Would Not Program Again by yummyfajitas on Tuesday January 14, 2014 @02:45PM (#7059229)
If we want to call any of the methods on the wrapped type we have to call directly to the wrapped type violating Demeter.

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.

Re:Scala – 1 Star Would Not Program Again by noelwelsh on Tuesday January 14, 2014 @02:37PM (#7059187)
Unboxed tagged types to the rescue:

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.

Re:Scala – 1 Star Would Not Program Again by kasey_junk on Tuesday January 14, 2014 @02:49PM (#7059250)
Tagged types also have their problems.

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.

Re:Scala – 1 Star Would Not Program Again by noelwelsh on Tuesday January 14, 2014 @02:55PM (#7059278)
It seems you've done a lot more with them than I have. I'm looking forward to crashing the compiler -- the true badge of honour amongst Scala developers ;-)
Re:Scala – 1 Star Would Not Program Again by yummyfajitas on Tuesday January 14, 2014 @04:47PM (#7059988)
They absolutely shouldn't propagate.

    val x = 1.0 @@ Kilograms
    val y = x*x
y is not a Double @@ Kilograms.
Re:Scala – 1 Star Would Not Program Again by kasey_junk on Wednesday January 15, 2014 @10:34AM (#7063838)
In many cases I'd like it to be.
Re:Scala – 1 Star Would Not Program Again by laureny on Tuesday January 14, 2014 @03:40PM (#7059550)
Value classes make tagged types obsolete:

http://docs.scala-lang.org/overviews/core/value-classes.html

Re:Scala – 1 Star Would Not Program Again by noelwelsh on Tuesday January 14, 2014 @04:00PM (#7059690)
They still have uses for disambiguating implicits. There are at least four monoids for the Int: 0/+, 1/*, MinValue/Max, and MaxValue/Min. It is useful to tag them so one can specify which monoid one wants.