News for hackers. Stuff that matters.
Re:Clojure to die for by nbouscal on Tuesday March 11, 2014 @11:14AM (#7379668)
Whether or not it's a debate has nothing to do with whether or not your example is valid. I was just pointing out that it isn't.
Re:Clojure to die for by wes-exp on Tuesday March 11, 2014 @12:41PM (#7380415)
Out of curiosity, how would you define my example stringify function in Haskell with "no cost" safety around the argument type?
Re:Clojure to die for by Tuna-Fish on Tuesday March 11, 2014 @01:40PM (#7380823)
The typeclass that provides "toString" in haskell is "Show". It defines a few functions, of which the important one is "show", which takes the original type and returns a string. A function that is equivalent to the java-ish example is:

    stringify s = show s
No type definition is necessary, because the compiler can correctly infer the correct, most generic type:

   stringify :: (Show s) => s -> String
Or, for any s in type class Show, a function that makes s into a String. Note that dispatch is done statically.

Modern type systems eliminate most of the cost of type safety through good generics and type inference. Mainstream statically typed languages are just 20-30 years behind the state of the art.

(note that the example actually can be reduced to: stringify = show)