Earlier quoted context omitted.
Perl's a dynamic language, but return type can vary based on context. I once saw this really bite someone where the presence of parentheses on the left-hand side of the expression changed the behavior of the function being called on the right-hand side. Not fun to debug that one.
Exactly. Duck typing sucks. I don't know why it was invented...
class Stream s where
read :: s -> (a, s)
write :: a -> s -> s
and extend it to any type: instance Stream [Int] where
read s = ...
write a s = ...
instance Stream File where
...
and so on, and I can now pass any type that is a member of Stream, to a function that expects one.