ghci and source files

Simon Marlow marlowsd at gmail.com
Wed Jul 30 05:07:30 EDT 2008


Daniel Gorín wrote:
> On Jul 29, 2008, at 2:43 PM, Johannes Waldmann wrote:
> 
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>>
>>> data Target = Target TargetId (Maybe (StringBuffer,ClockTime))
>>
>> looks great. How is this intended to be used,
>> i.e. what should happen if there is an "edit/save" event in the IDE?
>> Then the IDE constructs a new StringBuffer from the buffer contents
>> and sends it to the GHC API? (what call?)
> 
> IIRC,you first set (or add) targets (with GHC.setTargets or 
> GHC.addTargets) and then run GHC.load indicating LoadAllTargets. I 
> *think* it will chose to use the StringBuffer only if the ClockTime is 
> newer than the file's timestamp. Thus, if the user updates and saves the 
> file between the creation of the StringBuffer and the actual call to 
> GHC.load, ghc will load the target from disk.

When the file is edited, you should put the edited content into the Target 
(use GHC.removeTarget/GHC.addTarget).  You can then load the program with 
GHC.load, or check a single module with GHC.checkModule.  checkModule 
doesn't rebuild the dependency tree or load the dependent modules, so if 
you think you need to do this then use GHC.load (with LoadUpTo) first.

When the file is saved, you should remove the StringBuffer from the Target, 
so that GHC will start using the on-disk source file again.

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list