Skip to content

ghc --make + hi-boot + class declarations = trouble

Consider the following test case:

-- Main.hs --
module Main where

import Module1
import Module2

main = return ()

-- Module1.hs --
module Module1 where

import Module2

class Three alpha where
  three :: Kappa alpha -> Kappa alpha -> Kappa alpha

-- Module1.hi-boot --
module Module2 where

import {-# SOURCE #-} Module1

data Kappa alpha = Kappa alpha alpha

f :: Three alpha => Kappa alpha -> alpha
f k = case three k k of
        Kappa x y -> x

-- Module1.hi-boot --
module Module1 where

class Three alpha where
  three :: Module2.Kappa alpha -> Module2.Kappa alpha
        -> Module2.Kappa alpha

-- Compilation Results --
cd /home/jcast/Source/tmp/	# -*-compilation-*-
Entering directory `/home/jcast/Source/tmp/'
ghc --make Main
Chasing modules from: Main
Compiling Module2          ( ./Module2.hs, ./Module2.o )

./Module2.hs:1:
    Failed to find interface decl for `Module1.$dmthree'
    from module `Module1'

Compilation exited abnormally with code 1 at Mon Oct  4
09:38:50

No, for the real program it's not strictly necessary to
employ mutual recursion between the modules in
question---but it is by far the most natural design.
Trac metadata
Trac field Value
Version 6.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution ResolvedWon'tFix
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information