Re:Type checking in Python
by markbnj on Sunday May 18, 2014 @12:38PM
(#7763473)
Yes, but I am talking about python as it is now, not what it might be if it combined the features of other languages. I don't know anything beyond the most basic characteristics of Haskell, so I can't really comment further.
[ Parent
| on HN ]
Re:Type checking in Python
by dbpatterson on Sunday May 18, 2014 @06:07PM
(#7764613)
Obviously there are some differences, but type classes are pretty similar to the way python normally works - type classes specify methods that a type has to have. So in the case of 'print', the type specifies that print can be called on anything that implements the method that turns a value into a string. The neat thing, of course, is that if you try to call it on something that doesn't implement that method, you get a compile error (and with proper tooling, I actually see red squiggles in my editor if I make this mistake, which is about as good as it can get).