GHCi grumbles (3)

George Russell
Wed, 15 Aug 2001 16:04:49 +0200

It should be possible to change
(1) the environment returned by System.getEnv
(2) the arguments returned by System.getArgs
(3) System.getProgName
in GHCi (for example, using :set).

By the way, my partial solution to grumble (1) is

:def modules (\ modulesStr -> do { let { imports = (\ modName -> ("import "++(if modName == "+" then "Prelude" else modName)++"\n")) (Prelude.words modulesStr) ; imod = "module XYZZY where \n"++(Prelude.concat imports) } ; Prelude.writeFile "/tmp/XYZZY.hs" imod ; Prelude.return ":load /tmp/XYZZY.hs" } )

Now if only I had a Haskell function for replacing a Haskell declaration or
expression using layout with the appropriate ({/;/}) functions, I could write
a :def macro
   thing split over
   several lines)
 which put everything together and compiled it.  Is there a contest for 
"Worst Abuse of :def"?