Skip to content

Commit cc1f169

Browse files
authored
Merge pull request #488 from haskellfoundation/Bodigrim-patch-1
GHC-39999: add missing quotes
2 parents 2a30eea + 2c2122a commit cc1f169

File tree

1 file changed

+1
-1
lines changed
  • message-index/messages/GHC-39999/adding-number-to-string

1 file changed

+1
-1
lines changed

message-index/messages/GHC-39999/adding-number-to-string/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ Main.hs:1:16: error: [GHC-39999]
2020

2121
Given that Haskell is a strong statically typed language, it is not a surprise that adding numbers to strings gives a compile-time error. However, one could expect GHC to be unhappy about `"4"`, not about `5` as above! Let's take a deeper look on how the type checker works.
2222

23-
The compiler first encounters the operator `(+)` which has type `Num a => a -> a -> a`. Thus it infers that both arguments of `(+)` should be of the same type `a`. Looking at the first argument `5` does not reveal us what `a` is: it could be `Int`, could be `Double`, etc. But the second argument `4` is certainly `String`, so the compiler concludes that `a` should be `String`.
23+
The compiler first encounters the operator `(+)` which has type `Num a => a -> a -> a`. Thus it infers that both arguments of `(+)` should be of the same type `a`. Looking at the first argument `5` does not reveal us what `a` is: it could be `Int`, could be `Double`, etc. But the second argument `"4"` is certainly `String`, so the compiler concludes that `a` should be `String`.
2424

2525
Now the compiler looks again at the first argument `5`. Since the second argument of `(+)` is `String`, it infers that `5` must be `String` as well. In Haskell a numeric literal could be anything which has `instance Num`, so GHC searches for `instance Num String` but could not find one and bails out with an error.

0 commit comments

Comments
 (0)