Normalize the element type of ListPat, fix #14547

Authored by sighingnow on May 8 2018, 9:53 AM.

Description

Normalize the element type of ListPat, fix Trac #14547

Summary:
The element type of List maybe a type family instacen, rather than a trivial type.
For example in Trac 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: Trac #14547

Differential Revision: https://phabricator.haskell.org/D4624