tssm / up-to-date-real-world-haskell

I'm trying to update the Real World Haskell book
Other
792 stars 49 forks source link

Content missing in webpage preview #35

Open ftxi opened 4 years ago

ftxi commented 4 years ago

Hi, I was reading Chapter 6: Using Type Classes. I found several lines missing (for the declaration of UniqueId was unclear):

screenshot

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.