You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I was reading Chapter 6: Using Type Classes. I found several lines missing (for the declaration of UniqueId was unclear):
However, as I looked into the source, these lines are still there:
#+BEGIN_NOTE
The type and newtype keywords
Although their names are similar, the ~type~ and ~newtype~
keywords have different purposes. The ~type~ keyword gives us
another way of referring to a type, like a nickname for a friend.
Both we and the compiler know that ~[Char]~ and ~String~ names
refer to the same type.
In contrast, the ~newtype~ keyword exists to /hide/ the nature of
a type. Consider a ~UniqueID~ type.
#+CAPTION: Newtype.hs
#+BEGIN_SRC haskell
newtype UniqueID = UniqueID Int
deriving (Eq)
#+END_SRC
The compiler treats ~UniqueID~ as a different type from ~Int~. As
a user of a ~UniqueID~, we know only that we have a unique
identifier; we cannot see that it is implemented as an ~Int~.
#+END_NOTE
Perhaps this is a problem, but I am not sure at which level it arises.
The text was updated successfully, but these errors were encountered:
Hi,
I was reading Chapter 6: Using Type Classes. I found several lines missing (for the declaration of
UniqueId
was unclear):However, as I looked into the source, these lines are still there:
Perhaps this is a problem, but I am not sure at which level it arises.
The text was updated successfully, but these errors were encountered: