Commit 280de0c1 authored by Ben Gamari's avatar Ben Gamari 🐢

Revert "Normalize the element type of ListPat, fix #14547"

This reverts commit 361d23a8.
parent 37acca7e
......@@ -790,13 +790,10 @@ translatePat fam_insts pat = case pat of
-- overloaded list
ListPat (ListPatTc elem_ty (Just (pat_ty, _to_list))) lpats
| Just e_ty <- splitListTyConApp_maybe pat_ty
, (_, norm_e_ty) <- normaliseType fam_insts Nominal e_ty
-- e_ty can be a type family instance, like
-- `It (List a)`, but we prefer `a`, see Trac #14547
, (_, norm_elem_ty) <- normaliseType fam_insts Nominal elem_ty
-- elem_ty is frequently something like
-- `Item [Int]`, but we prefer `Int`
, norm_elem_ty `eqType` norm_e_ty ->
, norm_elem_ty `eqType` e_ty ->
-- We have to ensure that the element types are exactly the same.
-- Otherwise, one may give an instance IsList [Int] (more specific than
-- the default IsList [a]) with a different implementation for `toList'
{-# 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
......@@ -100,7 +100,6 @@ 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'])
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment