
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dear all, how does ghci (actually, the ghc API functions) access the file system? (It needs to check whether source files had been updated.) Is it possible to insert an abstraction layer there? E.g. imagine the sources are not on the file system, but in Eclipse edit buffers. - Any hints appreciated. J.W. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEUEARECAAYFAkiPJUEACgkQDqiTJ5Q4dm99LQCXcaCtKnvEsmoGdJ+UQ93A2x0Z 2ACbBfaSZsvU0xHeh/jQbZZjI5VAEdQ= =eQ4p -----END PGP SIGNATURE-----

Hi If you just want to compile from (Eclipse) edit buffers instead of source files, I think you can do this with the ghc api. Look at the Target type. The following is pasted from main/HscTypes.lhs -- | A compilation target. -- -- A target may be supplied with the actual text of the -- module. If so, use this instead of the file contents (this -- is for use in an IDE where the file hasn't been saved by -- the user yet). data Target = Target TargetId (Maybe (StringBuffer,ClockTime)) Hope this helps Daniel On Jul 29, 2008, at 11:12 AM, Johannes Waldmann wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Dear all, how does ghci (actually, the ghc API functions) access the file system? (It needs to check whether source files had been updated.) Is it possible to insert an abstraction layer there? E.g. imagine the sources are not on the file system, but in Eclipse edit buffers. - Any hints appreciated. J.W. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iEUEARECAAYFAkiPJUEACgkQDqiTJ5Q4dm99LQCXcaCtKnvEsmoGdJ+UQ93A2x0Z 2ACbBfaSZsvU0xHeh/jQbZZjI5VAEdQ= =eQ4p -----END PGP SIGNATURE----- _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

-----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?) thanks - J.W. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkiPVqsACgkQDqiTJ5Q4dm9ZsgCfT/GqfQmqIkFx4a1vL0Bg44nM YnUAoKEK7PSnMVOIVOoaaCu6zzOHje3s =1c4v -----END PGP SIGNATURE-----

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. But I'm mostly guessing here, so you should probably try it out and see if it works :) Daniel

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
participants (3)
-
Daniel Gorín
-
Johannes Waldmann
-
Simon Marlow