However, not "in general". The general problem is that bogus data leads to an irreparable situation. To fix that bug, you have to find out who broke the data. Consider for example, a circle in a linked list. You would need quite an expressive type system to prevent that statically (dependent types might suffice? Theorem provers are the ultimate hammer).
a = 1:a makeCircle rst = rst ++ makeCircle rst
The thing is that a circular list is actually an infinite list in Haskell. ;)These aren't "circles" per se, they are partially evaluated recursive structures. If you expand them you end up with evaluated list structures that are non-self referential.
"a" + b"s" is an error in Python 3.
Static types solve it earlier though, especially for little-exercised code paths which could be forgotten or missed in testing.
The programmer would probably just try to fix it via str(u"a")+"s" or u"a" + unicode("s").
Since you have brought up the general case, the origins of many bugs involve something sophisticated going wrong which would require you to encode much of your program (hopefully not too redundantly) into a Turing-complete type system. Rather than stuffing square pegs into round holes, you could just write the appropriate error handling code (or even just asserts).
alias hncomment='fold -w 77 -s | sed "s/^/ /" | pbcopy'
use:
echo "blah blah blah" | hncomment
command-v
Thus: The reason this approach is problematic is that it means the traceback for
an unexpected UnicodeDecodeError or UnicodeEncodeError in a large Python 2.x
code base almost never points you to the code that is broken. Instead, you
have to trace the origins of the data in the failing operation, and try to
figure out where the unexpected 8-bit or Unicode code string was introduced.
By contrast, Python 3 is designed to fail fast in most situations[...]