News for hackers. Stuff that matters.
Re:Experiment: Unit testing isn't enough; You need static ty... by sbmassey on Wednesday June 20, 2012 @10:13AM (#4137039)
Haskell type classes are sufficiently flexible to represent things like 'does this type have a next method' without having to instrument the actual type.
Re:Experiment: Unit testing isn't enough; You need static ty... by pimentel on Wednesday June 20, 2012 @10:33AM (#4137137)
But could that kind of type system be considered similar to the usual Java-like little-flexible static typing? I think I would prefer a static vs dynamic implemented as Java vs Python (since those are usually the subjects on every one of these discussions)
Re:Experiment: Unit testing isn't enough; You need static ty... by hythloday on Wednesday June 20, 2012 @10:44AM (#4137200)
It's identical, conceptually. A type class can be thought of as a degenerate kind of Adapter pattern.
Re:Experiment: Unit testing isn't enough; You need static ty... by ufo on Wednesday June 20, 2012 @05:17PM (#4139161)
ALthough the name is confusing type classes are very much like interfaces in Java: you define a set of operations that you want and then instantiate concrete types to that interface.

The major differences between type classes and interfaces are: * In Java interfaces the interfaced type is restricted to the first argument (the this). In Haskell interfaces the interfaced type can also appear on return values and arguments. * In Java you need to decide what interfaces to implement when you create your class. Haskell allows interfaces to be implemented for previously existing types. * Java allows for subtyping. You can turn a monomorphic program into a polymorphic one just by creating subclasses while in Haskell you would need to rewrite your code to be explicitly polymorphic.