[GHC] #15962: Type family & typeclass interaction suppresses errors

GHC ghc-devs at haskell.org
Wed Nov 28 11:51:30 UTC 2018


#15962: Type family & typeclass interaction suppresses errors
-------------------------------------+-------------------------------------
           Reporter:  madgen         |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  ⊥
          Component:  Compiler       |           Version:  8.4.3
  (Type checker)                     |
           Keywords:  type family,   |  Operating System:  Unknown/Multiple
  typeclass, error message           |
       Architecture:                 |   Type of failure:  Incorrect
  Unknown/Multiple                   |  error/warning at compile-time
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 The following program despite having a hole and an undefined variable
 `iDontExist` *quietly* fails to compile on 8.4.3 and 8.4.4. It produces
 errors as expected on 8.6.1 and 8.6.2.

 By quietly failing, I mean it fails on CLI but without producing any error
 messages and in GHCI. It just says "Failed, no modules loaded."

 {{{#!hs
 {-# LANGUAGE GADTs #-}
 {-# LANGUAGE TypeInType #-}
 {-# LANGUAGE TypeFamilies #-}
 {-# LANGUAGE TypeOperators #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE FlexibleInstances #-}

 module Bug where

 import Data.Kind (Type)

 type Exp a = a -> Type
 type family Eval (e :: Exp a) :: a

 data OpKind = Conjunction

 data Dual (k :: OpKind) :: Exp OpKind

 data Map :: (a -> Exp b) -> [ a ] -> Exp [ b ]

 type instance Eval (Map f (a ': as)) = Eval (f a) ': Eval (Map f as)

 data Big :: [ OpKind ] -> Type where
   Big  :: [ Big ks ] -> Big ('Conjunction ': ks)

 dualBig :: Big ks -> Big (Eval (Map Dual ks))
 dualBig = _

 instance Semigroup (Big a) where
   Big xs <> Big ys = Big (xs <> ys)

 instance Monoid (Big ('Conjunction ': ks)) where
   mempty = iDontExist

 flatten :: Monoid (Big ks) => Big (k ': k ': ks) -> Big ks
 flatten = undefined
 }}}

 Sorry, the example is a bit big but almost any change causes the errors to
 appear again including the `Monoid` constraint on `flatten`.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15962>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list