Skip to content

Commit 098363a

Browse files
Merge pull request #431 from TauOmicronMu/07626
Add docs for GHC-07626
2 parents b0e5d77 + 66f30c6 commit 098363a

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module Example where
2+
3+
merge [] bs rest = bs ++ rest
4+
merge as [] rest = as ++ rest
5+
merge (a:as) (b:bs) rest
6+
| a > b = merge as (b:bs) (a:rest)
7+
| otherwise = merge (a:as) bs (b:rest)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module Example where
2+
3+
merge [] bs rest = bs ++ rest
4+
merge as [] rest = as ++ rest
5+
merge a:as (b:bs) rest
6+
| a > b = merge as (b:bs) (a:rest)
7+
| otherwise = merge (a:as) bs (b:rest)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Parse error in pattern
3+
---
4+
5+
This error occurs because we haven’t properly pattern matched on the list in our definition of the `merge` function. In particular, the parentheses are missing. The type here is a list, which means our options are to match on either the empty list, `[]`, or a list with head and tail, `(a:as)`. By omitting the parentheses around `a:as`, the compiler reads this as an argument, `a`, followed by a misplaced infix cons `(:)` operator, rather than considering the `:` to be part of the list being matched.
6+
7+
# Error Message
8+
```
9+
Example.hs:5:1: error: [GHC-07626] Parse error in pattern: merge
10+
|
11+
5 | merge a:as (b:bs) rest
12+
| ^^^^^^^
13+
14+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Parse error in pattern
3+
summary: Compiler not able to parse pattern.
4+
severity: error
5+
introduced: 9.6.1
6+
---
7+
8+
This error occurs when the compiler is unable to understand a pattern that you're attempting to match on.
9+
10+
## Example text
11+
```
12+
Parse error in pattern: merge
13+
```
14+

0 commit comments

Comments
 (0)