[Haskell-cafe] Re: [Haskell] ANN: HLint 1.0

Claus Reinke claus.reinke at talk21.com
Fri Dec 26 17:22:23 EST 2008


>> You were asking about getting the output of ':show modules' into a
>> variable 'x', so that you can process it further. ':redir x :show modules'
>> should do just that. There is another example command for implementing
>> ':edit' this way (by now a native ghci command).
> 
> I think I'm seeing your meaning. So that brings me up to this:
> 
> let hlint _ = return $ unlines [":redir hlintvar1 :show modules", "let
> hlintvar2 = map (fst . break (==',') . drop 2 . snd . break (== '('))
> $ lines hlintvar1", ":! hlint (concat $ intersperse \" \" hlintvar2"]
> :def hlint hlint
> 
> This doesn't work. The issue is that :! is weird; for it to work, one
> need to pass each argument as a separate string, and it won't evaluate
> a variable.

It isn't just ':!', quoting/variable interpretation is generally rather
uncomfortable in GHCi scripting (so much so that I originally submitted
output redirection as a patch before figuring out that it could be done 
without patching GHCi - that surprise find was the motivation for posting
my findings as an email). Have you tried reading the mini tutorial that 
I keep mentioning and which the "using GHCi" page is pointing to? 
Here's the direct link:

http://www.haskell.org/pipermail/haskell-cafe/2007-September/032260.html

The discussion is rather brief, but that tutorial has several examples
that need to work around issues like this, ranging from simple but
tedious construct-the-command-string to extra levels of ':cmd' in
order to get extra levels of interpretation (when you need to construct
a command string from a variable that will be bound via a constructed
command string (see the definitions of ':find', ':le' or ':b(rowse)' - the 
latter is an example of using the info from ':show modules').

Claus



More information about the Haskell-Cafe mailing list