Opened 10 years ago

Closed 10 years ago

Last modified 45 years ago

#263 closed bug (Wont Fix)

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

Reported by: jcast Owned by: nobody
Priority: normal Milestone:
Component: Compiler Version: 6.2.1
Keywords: Cc:
Operating System: Architecture:
Type of failure: Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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.

Change History (2)

comment:1 Changed 10 years ago by simonpj

  • Status changed from assigned to closed
Logged In: YES 
user_id=50165

You can't put class signatures in a hi-boot file.  (The 
documentation should say this, and will soon; and the error 
message will be better.)

Instead, write the sig for the class op as a separate top-level 
defn in the hi-boot file
  three :: Three alpha => ...type as before...

comment:2 Changed 10 years ago by jcast

Logged In: YES 
user_id=762054

Ok, thanks for the clarification.
Note: See TracTickets for help on using tickets.