Opened 3 years ago

Closed 3 years ago

Last modified 2 years ago

#12905 closed bug (duplicate)

Core lint failure with pattern synonym and levity polymorphism

Reported by: bgamari Owned by:
Priority: normal Milestone: 8.2.1
Component: Compiler (Type checker) Version: 8.0.1
Keywords: LevityPolymorphism, Typeable Cc: simonpj, goldfire
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash or panic Test Case:
Blocked By: Blocking:
Related Tickets: #11714 Differential Rev(s):
Wiki Page:

Description (last modified by bgamari)

Yet another program from the type-indexed Typeable effort which breaks GHC (master branch as of 3bd1dd4d75fde3b922d4de08c16f29bdeb8e05d7) with a core lint error,

{-# LANGUAGE GADTs, TypeOperators, PatternSynonyms, TypeInType, PolyKinds, RankNTypes #-}
module T where

import GHC.Exts
import Data.Kind
import Data.Type.Equality

data TypeRep (a :: k) where
    TrTyCon :: TypeRep (a :: k)
    TrApp   :: forall k1 k2 (a :: k1 -> k2) (b :: k1).
               TypeRep (a :: k1 -> k2)
            -> TypeRep (b :: k1)
            -> TypeRep (a b)
    TrFun   :: forall (r1 :: RuntimeRep) (r2 :: RuntimeRep) (a :: TYPE r1) (b :: TYPE r2).
               TypeRep a
            -> TypeRep b
            -> TypeRep (a -> b)

pattern TRFun :: forall k (fun :: k). ()
              => forall (r1 :: RuntimeRep) (r2 :: RuntimeRep) (arg :: TYPE r1) (res :: TYPE r2). (k ~ Type, fun ~~ (arg -> res))
              => TypeRep arg
              -> TypeRep res
              -> TypeRep fun
pattern TRFun arg res <- TrFun arg res
  where TRFun arg res = TrFun arg res

This program produces many core lint errors, although all of them fall into only a few classes. Here's one,

*** Core Lint errors : in result of Desugar (before optimization) ***
<no location info>: warning:
    In the coercion ‘Sym (Sym cobox_a3fT |> Sym cobox_a3fU)’
    Kind application error in
      type ‘((->) |> <*>_N ->_N <*>_N ->_N Sym cobox) a’
      Function kind = * -> * -> k
      Arg kinds = [(a, TYPE r1)]
<no location info>: warning:
    [RHS of $d~~_a3fO :: (fun :: k) ~~ ((a -> b) :: *)]
    Kind application error in
      coercion ‘Sym
                  (Sym
                     (<(->)>_N |> ((<*>_N -> <*>_N -> Sym cobox_a3fU)
                                   ; Sym (<*>_N -> <*>_N -> Sym cobox_a3fH))) |> (<*>_N
                                                                                  -> <*>_N
                                                                                  -> Sym
                                                                                       cobox_a3fU)) <a>_N’
      Function kind = * -> * -> *
      Arg kinds = [(a, TYPE r1)]

This may be yet another case of the kind of (->) being too restrictive (#11714) since a -> b appears to be lifted to the coercion TyConAppCo role (->) [a, b].

Change History (7)

comment:1 Changed 3 years ago by bgamari

Description: modified (diff)

comment:2 Changed 3 years ago by bgamari

Description: modified (diff)

comment:3 Changed 3 years ago by bgamari

Keywords: levity-polymorphic added
Summary: Core lint with pattern synonymCore lint failure with pattern synonym and levity polymorphism

comment:4 Changed 3 years ago by goldfire

Keywords: LevityPolymorphism added; levity-polymorphic removed

comment:5 Changed 3 years ago by goldfire

Looks like #11714 to me.

comment:6 Changed 3 years ago by bgamari

Resolution: duplicate
Status: newclosed

comment:7 Changed 2 years ago by simonpj

Keywords: Typeable added; typeable removed
Note: See TracTickets for help on using tickets.