Skip to content

Commit d526158

Browse files
authored
Implement GHC-16437 (#504)
1 parent 1d6d1be commit d526158

File tree

7 files changed

+42
-0
lines changed

7 files changed

+42
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{-# LANGUAGE GADTs #-}
2+
{-# LANGUAGE StandaloneDeriving #-}
3+
4+
module Deriving_gadt where
5+
6+
data T a b where
7+
Mk :: Int -> b -> T Int b
8+
9+
deriving instance Functor (T a)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Deriving_gadt where
2+
3+
data T a b where
4+
Mk :: Int -> b -> T Int b
5+
deriving (Functor)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
title: Attempt at using deriving clause with GADT.
3+
---
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Higher_rank where
2+
3+
-- unfortunately we just need a rank 1 type
4+
data Bad a = MkBad a deriving Eq
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{-# LANGUAGE RankNTypes #-}
2+
3+
module Higher_rank where
4+
5+
data Bad = MkBad (forall a. a) deriving Eq
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
title: Use of higher-rank types with a deriving clause.
3+
---
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: Bad Constructor used with deriving clause
3+
summary: Standard deriving fails on GADTs and higher-rank types
4+
severity: error
5+
introduced: 9.6.1
6+
---
7+
8+
The deriving mechanism expects constructors of a particular form. When the constructors do not comport to this form, this error is thrown:
9+
10+
• Can't make a derived instance of ‘Functor (T a)’:
11+
Constructor ‘Mk’ is a GADT
12+
• In the data declaration for ‘T’
13+
Suggested fix: Use a standalone deriving declaration instead

0 commit comments

Comments
 (0)