#15962 closed bug (fixed)

Type family & typeclass interaction suppresses errors

Reported by: madgen Owned by:
Priority: normal Milestone: 8.8.1
Component: Compiler (Type checker) Version: 8.4.3
Keywords: TypedHoles, newcomer Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect error/warning at compile-time Test Case: typecheck/should_fail/T15962
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."

{-# 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.

Change History (3)

comment:1 Changed 10 months ago by RyanGlScott

Keywords: TypedHoles newcomer added; type family typeclass error message removed

Interesting program. It's conceivable that this was fixed by Tritlo's recent work on typed holes (possibly commit 39de4e3d33dd9879398062620ad00b1e3b8481ce, although I haven't confirmed this). It is fixed now though, thankfully.

In any case, I can't recall having a test case quite like this one (the test case from #15321, which the aforementioned commit fixed, requires Template Haskell), so it might be nice to add this as a test case as well. Any volunteers?

comment:2 Changed 10 months ago by Ryan Scott <ryan.gl.scott@…>

In 8d7496c/ghc:

Add a test case for #15962

Test Plan: make test TEST=T15962

Reviewers: RyanGlScott, bgamari

Reviewed By: RyanGlScott

Subscribers: rwbarton, carter

GHC Trac Issues: #15962

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

comment:3 Changed 10 months ago by RyanGlScott

Milestone: 8.8.1
Resolution: fixed
Status: newclosed
Test Case: typecheck/should_fail/T15962
Note: See TracTickets for help on using tickets.