
Hello fellow Haskellers, Does anyone know if/where I can find a specification for the .hi files generated by GHC? I ask because I want to write an omni-completion plugin for Vim to make Haskell hacking a bit nicer. Thanks, Rob Hoelz

Rob Hoelz wrote:
Does anyone know if/where I can find a specification for the .hi files generated by GHC? I ask because I want to write an omni-completion plugin for Vim to make Haskell hacking a bit nicer.
I think it's pretty much considered unspecified; but there's code to read and write it in compiler/iface/BinIface.hs in any GHC source tree. -- Chris Smith

On Nov 29, 2007, at 17:45 , Rob Hoelz wrote:
Does anyone know if/where I can find a specification for the .hi files generated by GHC? I ask because I want to write an omni-completion plugin for Vim to make Haskell hacking a bit nicer.
There isn't one. However, you can use a sufficiently recent GHC (works back to 6.6, dunno how much earlier) to dump it in a readable format: ghc --show-iface foo.hi -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

Does anyone know if/where I can find a specification for the .hi files generated by GHC? I ask because I want to write an omni-completion plugin for Vim to make Haskell hacking a bit nicer.
you might find it easier to use GHCi's :browse command
$ ghc -e ':browse Control.Concurrent.MVar'
modifyMVar :: MVar a -> (a -> IO (a, b)) -> IO b
modifyMVar_ :: MVar a -> (a -> IO a) -> IO ()
readMVar :: MVar a -> IO a
swapMVar :: MVar a -> a -> IO a
withMVar :: MVar a -> (a -> IO b) -> IO b
data MVar a = GHC.IOBase.MVar (GHC.Prim.MVar# GHC.Prim.RealWorld a)
addMVarFinalizer :: MVar a -> IO () -> IO ()
isEmptyMVar :: MVar a -> IO Bool
newEmptyMVar :: IO (MVar a)
newMVar :: a -> IO (MVar a)
putMVar :: MVar a -> a -> IO ()
takeMVar :: MVar a -> IO a
tryPutMVar :: MVar a -> a -> IO Bool
tryTakeMVar :: MVar a -> IO (Maybe a)
that is what the haskell mode plugins for vim use, for one
of their completion modes, anyway;-)
http://www.cs.kent.ac.uk/~cr3/toolbox/haskell/Vim/
(actually, that completion is wrt to imported identifiers,
so we simply do a ':browse *

Hi
Does anyone know if/where I can find a specification for the .hi files generated by GHC? I ask because I want to write an omni-completion plugin for Vim to make Haskell hacking a bit nicer.
you might find it easier to use GHCi's :browse command
Or you might want to try haddock with the --hoogle command. Similar thing, slightly different format - depends what suits you. Thanks Neil

Claus Reinke
Does anyone know if/where I can find a specification for the .hi files generated by GHC? I ask because I want to write an omni-completion plugin for Vim to make Haskell hacking a bit nicer.
you might find it easier to use GHCi's :browse command
$ ghc -e ':browse Control.Concurrent.MVar' modifyMVar :: MVar a -> (a -> IO (a, b)) -> IO b modifyMVar_ :: MVar a -> (a -> IO a) -> IO () readMVar :: MVar a -> IO a swapMVar :: MVar a -> a -> IO a withMVar :: MVar a -> (a -> IO b) -> IO b data MVar a = GHC.IOBase.MVar (GHC.Prim.MVar# GHC.Prim.RealWorld a) addMVarFinalizer :: MVar a -> IO () -> IO () isEmptyMVar :: MVar a -> IO Bool newEmptyMVar :: IO (MVar a) newMVar :: a -> IO (MVar a) putMVar :: MVar a -> a -> IO () takeMVar :: MVar a -> IO a tryPutMVar :: MVar a -> a -> IO Bool tryTakeMVar :: MVar a -> IO (Maybe a)
that is what the haskell mode plugins for vim use, for one of their completion modes, anyway;-)
http://www.cs.kent.ac.uk/~cr3/toolbox/haskell/Vim/
(actually, that completion is wrt to imported identifiers, so we simply do a ':browse *
'; another completion mode is based on haddock indices, and then there are the standard occurs-in-imported-source-files and occurs-in-tags-file completions) claus
Wow! Thanks for saving me a ton of work, everyone!

"Claus Reinke"
you might find it easier to use GHCi's :browse command
While ghc -e works, this no longer work within GHCi? Prelude> :b Control.Concurrent.MVar module 'Control.Concurrent.MVar' is not interpreted -k -- If I haven't seen further, it is by standing in the footprints of giants

On Fri, Nov 30, 2007 at 08:55:51AM +0000, Neil Mitchell wrote:
Hi
Prelude> :b Control.Concurrent.MVar module 'Control.Concurrent.MVar' is not interpreted
:b now defaults to :breakpoint, you want :browse
That's a questionable decision, IMO: - it changes behavior - I expect :browse to be used more often, so it deserves the sort :b version (:bro is not that short) On the other hand, this change can have an (unintended?) feature advertising effect ;-) Best regards Tomasz

On Sun, Dec 02, 2007 at 05:45:48AM +0100, Tomasz Zielonka wrote:
On Fri, Nov 30, 2007 at 08:55:51AM +0000, Neil Mitchell wrote:
Hi
Prelude> :b Control.Concurrent.MVar module 'Control.Concurrent.MVar' is not interpreted
:b now defaults to :breakpoint, you want :browse
That's a questionable decision, IMO: - it changes behavior - I expect :browse to be used more often, so it deserves the sort :b version (:bro is not that short)
On the other hand, this change can have an (unintended?) feature advertising effect ;-)
It's not a decision at all. :b is the first command starting with b, which was browse yesterday, is breakpoint today, and tomorrow will be something you've never heard of. It's inherently fragile, and shouldn't be relied on in scripts - and if :b does anything funny, spell out the command! (There is a case to be made for explicitly defining short forms of commands - but that is not what :b is, and making this case should only be done in a new thread.) Stefan

On Sat, Dec 01, 2007 at 10:01:13PM -0800, Stefan O'Rear wrote:
On Sun, Dec 02, 2007 at 05:45:48AM +0100, Tomasz Zielonka wrote:
That's a questionable decision, IMO: - it changes behavior - I expect :browse to be used more often, so it deserves the sort :b version (:bro is not that short)
On the other hand, this change can have an (unintended?) feature advertising effect ;-)
It's not a decision at all. :b is the first command starting with b, which was browse yesterday, is breakpoint today, and tomorrow will be something you've never heard of.
I haven't thought about it this way. OK, so _this_ is the questionable decision: allowing the ambiguous shortcut.
It's inherently fragile, and shouldn't be relied on in scripts
I am only relying on it in my brain's procedural memory and I guess it's going to fix itself eventually ;-) Best regards Tomasz

Stefan O'Rear wrote: > On Sun, Dec 02, 2007 at 05:45:48AM +0100, Tomasz Zielonka wrote: >> On Fri, Nov 30, 2007 at 08:55:51AM +0000, Neil Mitchell wrote: >>> Hi >>> >>>> Prelude> :b Control.Concurrent.MVar >>>> module 'Control.Concurrent.MVar' is not interpreted >>> :b now defaults to :breakpoint, you want :browse >> That's a questionable decision, IMO: >> - it changes behavior >> - I expect :browse to be used more often, so it deserves the sort >> :b version (:bro is not that short) >> >> On the other hand, this change can have an (unintended?) feature >> advertising effect ;-) > > It's not a decision at all. :b is the first command starting with b, > which was browse yesterday, is breakpoint today, and tomorrow will be > something you've never heard of. Well, it wasn't quite that accidental. I noticed that :b had changed, made a unilateral decision that :breakpoint was likely to be typed more often than :browse, and decided to leave it that way. > It's inherently fragile, and shouldn't > be relied on in scripts - and if :b does anything funny, spell out the > command! FWIW, I wish we'd never implemented the "first prefix" match behaviour, unextensible as it is. We could change it for 6.10... Cheers, Simon

Rob Hoelz wrote:
Hello fellow Haskellers,
Does anyone know if/where I can find a specification for the .hi files generated by GHC? I ask because I want to write an omni-completion plugin for Vim to make Haskell hacking a bit nicer.
You don't want to do that. The .hi files can expose internal implementation details that shouldn't be visible to callers of the library. (E.g., so that GHC can inline things across module boundaries.) What you want to play with is the :browse command. ;-) (Thinking about it... some kind of tool for easily producing a propper "interface file" that 3rd party tools can use would probably be quite a useful thing... I wonder how hard it would be to implement?)
participants (10)
-
Andrew Coppin
-
Brandon S. Allbery KF8NH
-
Chris Smith
-
Claus Reinke
-
Ketil Malde
-
Neil Mitchell
-
Rob Hoelz
-
Simon Marlow
-
Stefan O'Rear
-
Tomasz Zielonka