• Ben Gamari's avatar
    Normalize the element type of ListPat, fix #14547 · 981bf471
    Ben Gamari authored
    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
    981bf471
T14547.hs 313 Bytes