logo       

[ ghc-Bugs-1201666 ] Default methods not in scope for spliced-in instances?: msg#00061

lang.haskell.glasgow.bugs

Subject: [ ghc-Bugs-1201666 ] Default methods not in scope for spliced-in instances?

Bugs item #1201666, was opened at 2005-05-13 17:16
Message generated for change (Comment added) made by sbronson
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1201666&group_id=8032

Category: Template Haskell
Group: 6.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Samuel Bronson (sbronson)
Assigned to: Simon Peyton Jones (simonpj)
Summary: Default methods not in scope for spliced-in instances?

Initial Comment:
This is a literate haskell bugreport. Save it to
DefaultMethodScopeTH.lhs.

I noticed a problem with instantiating a typeclasse
from Template
Haskell in the same module that defined it. I've bumped
into this
twice close together now, so I figure I really ought to
report it now.

> {-# OPTIONS_GHC -fth #-}
>
> module DefaultMethodScopeTH where

First, define a typeclass with a default method.

This is probably not a very usefull class, but nobody
wants me to drag
half of the module I'm actually working on into this ;-).

> class Foo a where
> foo :: a -> a
> foo = id

Now try to instantiate it from TH with the default method.

> $([d| instance Foo () where |])

Nothing particularly complicated, right?

But when I try to actually build it, I get this:

$ ghc --make DefaultMethodScopeTH.lhs
Chasing modules from: DefaultMethodScopeTH.lhs
Compiling DefaultMethodScopeTH (
DefaultMethodScopeTH.lhs, DefaultMethodScopeTH.o )

DefaultMethodScopeTH.lhs:22:7:
GHC internal error: `DefaultMethodScopeTH.$dmfoo'
is not in scope
In the definition of `foo': foo =
DefaultMethodScopeTH.$dmfoo
In the definition for method `foo'
In the instance declaration for `Foo ()'

Kind of nasty, eh?


----------------------------------------------------------------------

>Comment By: Samuel Bronson (sbronson)
Date: 2005-05-13 17:29

Message:
Logged In: YES
user_id=237753

Ugg, this looks horrible. That'll teach me to write bug
reports in Emacs, I guess... the autogenerated email looks
very slightly better, but not much. I'm attaching the original.

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1201666&group_id=8032


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise