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

Claus Reinke claus.reinke at talk21.com
Mon Dec 22 13:49:16 EST 2008

> Well, sort of. Ok, we can parse that. Let's assume a variable x holds
> the output of :show modules as a String. We call lines on it, then map
> words on it, do a !! 2 on it, and we get ["Util.hs,", "Recorder.hs,",
> "Game.hs,", "Monadius.hs,", "Demo.hs,"]. Chuck in a map (filter (\=
> ',')), and we get a good list. We can turn the list into a string
> suitable for hlint with a quick unwords.
> So our long sought after command becomes ':def hoogle (\_ -> return $
> ":! " ++ (unwords $ map (filter (\= ',')) $ (map words $ lines x) !!
> 2))'. But wait, how do we get 'x'? How do we call :show modules inside
> a Haskell expression? I have carefully looked over
> http://haskell.org/haskellwiki/GHC/GHCi#Using_GHCi and
> http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-commands.html
> and my conclusion is that you can't. You can't do a let x = :show
> modules, there is no function which will take ":show modules", and so
> on. :functions can accept Haskell output, but it's a one-way barrier.
> It's no good writing Haskell functions which need information from the
> :functions.

The first url includes a link to a .ghci mini-tutorial (section 4) that, 
among other things, implements 

    :redir <var> <cmd>      -- execute <cmd>, redirecting stdout to <var>

Happy Holidays!-)

More information about the Haskell-Cafe mailing list