diff options
author | HE, Tao <sighingnow@gmail.com> | 2018-05-08 10:53:41 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-05-08 14:44:57 -0400 |
commit | ba6e445e1cf31957f2a327a73f9f66cfa7f24e26 (patch) | |
tree | 0fc4936c859b3b97d5b1405ac9bc376aa7628dfb /testsuite/tests/deSugar | |
parent | 849547bd3a5bc6876268c94f97bf3e79c31340ec (diff) | |
download | haskell-ba6e445e1cf31957f2a327a73f9f66cfa7f24e26.tar.gz |
Normalize the element type of ListPat, fix #14547
Summary:
The element type of `List` maybe a type family instacen, rather than a trivial type.
For example in Trac #14547,
```
{-# LANGUAGE TypeFamilies, OverloadedLists #-}
class Foo f where
type It f
foo :: [It f] -> f
data List a = Empty | a :! List a deriving Show
instance Foo (List a) where
type It (List a) = a
foo [] = Empty
foo (x : xs) = x :! foo xs
```
Here the element type of `[]` is `It (List a)`, we should also normalize
it as `a`.
Test Plan: make test TEST="T14547"
Reviewers: bgamari
Reviewed By: bgamari
Subscribers: thomie, carter
GHC Trac Issues: #14547
Differential Revision: https://phabricator.haskell.org/D4624
Diffstat (limited to 'testsuite/tests/deSugar')
-rw-r--r-- | testsuite/tests/deSugar/should_compile/T14547.hs | 15 | ||||
-rw-r--r-- | testsuite/tests/deSugar/should_compile/all.T | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/testsuite/tests/deSugar/should_compile/T14547.hs b/testsuite/tests/deSugar/should_compile/T14547.hs new file mode 100644 index 0000000000..02ff2e618c --- /dev/null +++ b/testsuite/tests/deSugar/should_compile/T14547.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE OverloadedLists #-} +{-# LANGUAGE TypeFamilies #-} + +module T14547 where + +class Foo f where + type It f + foo :: [It f] -> f + +data List a = Empty | a :! List a deriving Show + +instance Foo (List a) where + type It (List a) = a + foo [] = Empty + foo (x : xs) = x :! foo xs diff --git a/testsuite/tests/deSugar/should_compile/all.T b/testsuite/tests/deSugar/should_compile/all.T index 2d361464a6..14140737d8 100644 --- a/testsuite/tests/deSugar/should_compile/all.T +++ b/testsuite/tests/deSugar/should_compile/all.T @@ -100,6 +100,7 @@ test('T13290', normal, compile, ['']) test('T13257', normal, compile, ['']) test('T13870', normal, compile, ['']) test('T14135', normal, compile, ['']) +test('T14547', normal, compile, ['-Wincomplete-patterns']) test('T14773a', normal, compile, ['-Wincomplete-patterns']) test('T14773b', normal, compile, ['-Wincomplete-patterns']) test('T14815', [], run_command, ['$MAKE -s --no-print-directory T14815']) |