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
Copy file name to clipboardExpand all lines: source_md/making-our-own-types-and-typeclasses.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1876,7 +1876,7 @@ Let's make some `Frank` values and check out their types.
1876
1876
1877
1877
```{.haskell:hs}
1878
1878
ghci> :t Frank {frankField = Just "HAHA"}
1879
-
Frank {frankField = Just "HAHA"} :: Frank [Char] Maybe
1879
+
Frank {frankField = Just "HAHA"} :: Frank String Maybe
1880
1880
ghci> :t Frank {frankField = Node 'a' EmptyTree EmptyTree}
1881
1881
Frank {frankField = Node 'a' EmptyTree EmptyTree} :: Frank Char Tree
1882
1882
ghci> :t Frank {frankField = "YES"}
@@ -1885,9 +1885,9 @@ Frank {frankField = "YES"} :: Frank Char []
1885
1885
1886
1886
Hmm.
1887
1887
Because `frankField` has a type of form `a b`, its values must have types that are of a similar form as well.
1888
-
So they can be `Just "HAHA"`, which has a type of `Maybe [Char]` or it can have a value of `['Y','E','S']`, which has a type of `[Char]` (if we used our own list type for this, it would have a type of `List Char`).
1888
+
So they can be `Just "HAHA"`, which has a type of `Maybe String` or it can have a value of `['Y','E','S']`, which has a type of `[Char]` (if we used our own list type for this, it would have a type of `List Char`).
1889
1889
And we see that the types of the `Frank` values correspond with the kind for `Frank`.
1890
-
`[Char]` has a kind of `*` and `Maybe` has a kind of `* -> *`.
1890
+
`String` has a kind of `*` and `Maybe` has a kind of `* -> *`.
1891
1891
Because in order to have a value, it has to be a concrete type and thus has to be fully applied, every value of `Frank blah blaah` has a kind of `*`.
1892
1892
1893
1893
Making `Frank` an instance of `Tofu` is pretty simple.
0 commit comments