Skip to content

Commit ec3ae8e

Browse files
authored
Documented declConflict errors (documentationjs#281)
* Documented declConflict errors * Updated DeclConflict.md
1 parent 081ec82 commit ec3ae8e

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

errors/DeclConflict.md

+21-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
11
# `DeclConflict` Error
22

33
## Example
4-
4+
Each of these pairs will fail with a DeclConflict error.
55
```purescript
6-
module ShortFailingExample where
6+
module Main where
7+
8+
data T = Fail | Fail
9+
10+
data T1 = Fail1
11+
data T2 = Fail1
712
8-
...
13+
class Fail2
14+
data T3 = Fail2
915
```
1016

1117
## Cause
1218

13-
Explain why a user might see this error.
19+
This error occurs when a data constructor, type, or type class conflicts with another data constructor, type, or type class.
1420

1521
## Fix
22+
This can be fixed by using non-conflicting names or by putting conflicting names into a separate module. Then, if the names are later used together in a module they can be distinguished via a qualified import:
23+
```purescript
24+
module Main where
25+
26+
import Module1 as Module1 -- includes: data Works = Works
27+
import Module2 as Module2 -- includes: data Works = Works
1628
17-
- Suggest possible solutions.
29+
x :: Module1.Works
30+
x = Module1.Works
1831
19-
## Notes
32+
y :: Module2.Works
33+
y = Module2.Works
34+
```
2035

21-
- Additional notes.

0 commit comments

Comments
 (0)