3 ms·
I already 100% understand what you're saying. No need to clarify. You're misunderstanding me. >Once you understand that, this confusion makes about as much sen
by crimsonalucard 7y ago
I already 100% understand what you're saying. No need to clarify. You're misunderstanding me.
>Once you understand that, this confusion makes about as much sense as expecting an integer to be "empty".
My comment was in reference to the above. An empty number does make sense because of the of 1/0. There is nothing wrong in including a null in a set if there are operations that are illegal. Such operations can't return something so you can use a null to represent the absence of something. This is entirely different from an empty container type.
>So, coming from Python, the misunderstanding about why there's no "base case" for char as there is for string is understandable
The author is looking for a null value not an empty container type or "base case". I quote: "Haskell has no null definition of type Char,"
Basically he's looking for the equivalent of "None" in haskell. He has slight confusion in thinking that an empty container type or empty string is equivalent to a "None."
Because he literally said he's looking for a null he is indeed talking about all things associated with null.
The closest thing to null in Haskell is the maybe monad which is like null but without a runtime exception.
His confusion arises because he feels that if in haskell you can do this:
stringfunction (x:xs) = ...
stringfunction [] = ...
Then you should be able to do this:
charfunction x = ...
charfunction null = ...
which is impossible in haskell, so--->
I'm saying that similar functionality can be achieved with:
charfunction (Just x) = ...
charfunction Nothing = ...
The above is 100% handling a null, one of the main sources of runtime errors.
- inimino 7y agoWe're just pointing out different things. I'm pointing out the different semantics of single-quoted literals as the source of the confusion, with "empty char" being directly mentioned in the post as something that exists in Python, which, as of course you know, it doesn't. If the confusion was about how to add a nothing value to a type, why did it arise specifically in regards to Char, and not, say, Integer? The question "why are the char types different between Haskell and Python in this way" is best answered by pointing out that Python doesn't have a char type at all, and all of these things are strings. Of course, you're entirely correct that you can use a sum type to handle nulls.
- crimsonalucard 7y ago>If the confusion was about how to add a nothing value to a type, why did it arise specifically in regards to Char, and not, say, Integer? I illustrated earlier because of the similarity between char and str, he believed that because of recursive functions on str has base case [], he believed that char needed one too.