#3615: GHCi doesn't allow the use of imported data contructors
--------------------------------+-------------------------------------------
    Reporter:  blamario         |        Owner:         
        Type:  feature request  |       Status:  new    
    Priority:  normal           |    Milestone:         
   Component:  GHCi             |      Version:  6.10.4 
    Severity:  minor            |   Resolution:         
    Keywords:                   |   Difficulty:  Unknown
    Testcase:                   |           Os:  Linux  
Architecture:  x86              |  
--------------------------------+-------------------------------------------
Changes (by simonpj):

  * difficulty:  => Unknown
  * type:  bug => feature request

Comment:

 I can at least explain what is going on.
  * You compiled Imp and Main
  * So ghci can load them fast (by linking their .o files) and run them
 fast (using their compiled code).
  * But the downside is that all GHC knows about the module is what is
 recorded in the interface file, Main.hi and Imp.hi
  * You did not export D(..) from Main, so the interface file Main.hi
 didn't mention the data type D at all.
  * If, instead, you load Main ''interpreted'' (this is what `:load *Main`
 does) you get access to its entire top-level scope.

 The compiled/interpreted distinction is unfortunate, because it's really
 an implementation matter, but it shows up to users.  We could make it less
 obtrusive by recording more in interface files (e.g. recording enough info
 to reproduce the top-level environment of Main).  But it's more than just
 recording extra info; doing a full job would require doing less
 optimisation.  For example suppose you have
 {{{
 module Foo(b) where
   f x = <blah>
   g y = f (x+x)
 }}}
 When compiled, GHC inlines 'f' at its only call (in 'g'), and so there
 ''is'' no compiled code for 'f'.  Hence GHCi can't call it.  I'm reluctant
 to prevent non-exported things from being inlined in this way.  (I suppose
 it could be an -O2 thing.)

 Anyway, that's the explanation.
  * Would someone like to add a description to
 http://haskell.org/haskellwiki/GHC/GHCi?

 The situation could be improved with some effort.
   * Any volunteers?

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3615#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to