File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed
message-index/messages/GHC-58008/gadt-without-monobind Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE MonoLocalBinds #-}
2
+
3
+ module GADTWithoutMonoBind where
4
+
5
+ data A a where
6
+ A :: A ()
7
+
8
+ f :: A () -> ()
9
+ f A = ()
Original file line number Diff line number Diff line change
1
+ module GADTWithoutMonoBind where
2
+
3
+ data A a where
4
+ A :: A ()
5
+
6
+ f :: A () -> ()
7
+ f A = ()
Original file line number Diff line number Diff line change
1
+ ---
2
+ title : Pattern matching on GADTs without MonoLocalBinds
3
+ ---
4
+
5
+ ## Message
6
+
7
+ ```
8
+ GADTWithoutMonoBind.hs:7:3: warning: [GHC-58008] [-Wgadt-mono-local-binds]
9
+ Pattern matching on GADTs without MonoLocalBinds is fragile.
10
+ Suggested fix:
11
+ Enable any of the following extensions: GADTs, TypeFamilies
12
+ |
13
+ 7 | f A = ()
14
+ | ^
15
+ ```
16
+
17
+ ## Explanation
18
+
19
+ When using GADTs, the type system is different in the sense that it's not
20
+ possible to derive the principal type of the function ` f ` . Both
21
+ ` f :: A a -> () ` and ` f :: A () -> () ` can be considered the most general
22
+ typing for the function. The ` MonoLocalBinds ` extension uses a slightly more
23
+ conservative policy in order to be able to derive the type properly in such
24
+ cases.
You can’t perform that action at this time.
0 commit comments