Musing about very strong types and their accessors
In working through SJT, I was required to implement
lines. For the first time ever, I managed to break a Haskell program while running it instead of the type checker catching the problem. Feast your eyes on this:
*Main> mylines ts
["dog","cat"*** Exception: Prelude.tail: empty list
As usual, that got me thinking about how I got into the situation. And it hit me, that my main problem is that I had to do programming instead of creating a very strong type and related accessors.
In other words,
lines converts a sequence of lines into a the sequence we call a list.
It seems that I should be able to type a string consisting of carriage return delimeters as a lazy list which returns elements.
Hmm, just brainstorming.