Skip to content

Commit 836fd27

Browse files
committed
Add docs for GHC-04584
1 parent 1711a4f commit 836fd27

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: Expression syntax in pattern
3+
summary: There has been an attempt to pattern match on Expression syntax.
4+
severity: error
5+
introduced: 9.6.1
6+
---
7+
8+
## Example Text
9+
10+
```
11+
Expression syntax in pattern: [1 .. 10]
12+
```
13+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module Matchingdots where
2+
3+
-- If the input is [1..10], return 0, otherwise return 1
4+
f :: [Int] -> Int
5+
f xs
6+
| xs == [1..10] = 0
7+
| otherwise = 1
8+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module Matchingdots where
2+
3+
-- If the input is [1..10], return 0, otherwise return 1
4+
f :: [Int] -> Int
5+
f [1..10] = 0
6+
f _ = 1
7+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Using .. in pattern
3+
---
4+
5+
When pattern matching, Expressions are not allowed as patterns to be matched against. Instead, consider matching on a list, and using a conditional.
6+
7+
8+
# Error Message
9+
10+
```
11+
before_dots.hs:3:3: error: [GHC-04584]
12+
Expression syntax in pattern: [1 .. 10]
13+
|
14+
3 | f [1..10] = 0
15+
| ^^^^^^^
16+
```

0 commit comments

Comments
 (0)