Skip to content

Commit 646c3d1

Browse files
Bodigrimsmith558
andauthored
Update text of error messages to match recent GHCs (learnyouahaskell#65)
Co-authored-by: Stanislav (Stanley) Modrak <[email protected]>
1 parent 505cb73 commit 646c3d1

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

markdown/source_md/higher-order-functions.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,10 @@ What happens if we try to just do `multThree 3 4` in GHCI instead of binding it
131131

132132
```{.haskell:hs}
133133
ghci> multThree 3 4
134-
<interactive>:1:0:
135-
No instance for (Show (t -> t))
136-
arising from a use of `print' at <interactive>:1:0-12
137-
Possible fix: add an instance declaration for (Show (t -> t))
138-
In the expression: print it
139-
In a 'do' expression: print it
134+
<interactive>:1:1: error: [GHC-39999]
135+
• No instance for ‘Show (a0 -> a0)’ arising from a use of ‘print’
136+
(maybe you haven't applied a function to enough arguments?)
137+
• In a stmt of an interactive GHCi command: print it
140138
```
141139

142140
GHCI is telling us that the expression produced a function of type `a -> a` but it doesn't know how to print it to the screen.

markdown/source_md/starting-out.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ What about doing `5 + "llama"` or `5 == True`?
8585
Well, if we try the first snippet, we get a big scary error message!
8686

8787
```{.haskell: .ghci}
88-
• No instance for (Num String) arising from a use of ‘+’
89-
• In the expression: 5 + "llama"
88+
<interactive>:1:1: error: [GHC-39999]
89+
• No instance for ‘Num String’ arising from the literal ‘5’
90+
• In the first argument of ‘(+)’, namely ‘5’
91+
In the expression: 5 + "llama"
9092
In an equation for ‘it’: it = 5 + "llama"
9193
```
9294

@@ -102,6 +104,13 @@ We'll take a closer look at types a bit later.
102104
Note: you can do `5 + 4.0` because `5` is sneaky and can act like an integer or a floating-point number.
103105
`4.0` can't act like an integer, so `5` is the one that has to adapt.
104106

107+
::: {.hintbox}
108+
**Note:** GHC errors are all assigned unique identifiers such as `GHC-39999` above.
109+
Whenever you are stuck with a stubborn error, you can look it up at
110+
[https://errors.haskell.org/](https://errors.haskell.org/) to learn typical causes
111+
and solutions.
112+
:::
113+
105114
You may not have known it but we've been using functions now all along.
106115
For instance, `*` is a function that takes two numbers and multiplies them.
107116
As you've seen, we call it by sandwiching it between them.
@@ -777,8 +786,9 @@ What if we tried to make a shape like `[(1,2),(8,11,5),(4,5)]`?
777786
Well, we'd get this error:
778787

779788
```{.haskell: .ghci}
780-
• Couldn't match expected type ‘(a, b)’
781-
with actual type ‘(a0, b0, c0)’
789+
<interactive>:1:8: error: [GHC-83865]
790+
• Couldn't match expected type: (a, b)
791+
with actual type: (a0, b0, c0)
782792
• In the expression: (8, 11, 5)
783793
In the expression: [(1, 2), (8, 11, 5), (4, 5)]
784794
In an equation for ‘it’: it = [(1, 2), (8, 11, 5), (4, 5)]

0 commit comments

Comments
 (0)