Skip to content

Commit ef15d5a

Browse files
committed
Apply review suggestions
1 parent e9c9d88 commit ef15d5a

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

message-index/messages/GHC-01239/example1/after/IfInFunAppExpr.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ module IfInFunAppExpr where
33

44
-- Requires BlockArguments language extension to work
55
example :: Int
6-
example = length if True then [1] else
6+
example = length if True then [1] else []
77

88
-- Works without BlockArguments
9-
example :: Int
10-
example = length (if True then [1] else [])
9+
example2 :: Int
10+
example2 = length (if True then [1] else [])
1111

1212
-- Works without BlockArguments
13-
example2 :: Int
14-
example2 = length $ if True then [1] else []
13+
example3 :: Int
14+
example3 = length $ if True then [1] else []

message-index/messages/GHC-01239/example1/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Unexpected if expression in function application
33
---
44

5-
To pass If-Then-Else expressions as function argument we either have to surround it in parentheses,
5+
To pass If-Then-Else expressions as function arguments we either have to surround them in parentheses,
66
use function application operator `($)` or enable [`BlockArguments`](https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/block_arguments.html#extension-BlockArguments) extension.
77

88
## Error Message

message-index/messages/GHC-01239/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Unexpected if expression in function application
33
summary: If expression used as function argument
44
severity: error
5-
introduced: TODO
5+
introduced: 9.6.1
66
---
77

88
Unlike in many other languages, in Haskell the If-Then-Else construct is an expression, which means it returns a value that can be processed further.
@@ -15,5 +15,5 @@ putStrLn (ageMessage 10) -- You are too young to enter
1515
putStrLn (ageMessage 20) -- Welcome to the club
1616
```
1717

18-
Thinking of If-Then-Else expression as a value, we might want to pass it as an input to a function.
19-
If you do that you can run into the following error.
18+
Because If-Then-Else expressions return values, it makes sense to pass them as input to a function.
19+
However, without language extensions, Haskell's grammar requires parentheses around them in function argument positions.

0 commit comments

Comments
 (0)