reading ghc core files in vim

Donald Bruce Stewart dons at cse.unsw.edu.au
Fri Jul 23 22:33:01 EDT 2004


Great! Reading core gives you headaches for the first couple of weeks :)
This should certainly help people.

You should ask the haskell.org guys to put a link up at:
        http://www.haskell.org/libraries/#editormodes

-- Don

john:
> I have found the following filetype plugin for vim to be incredibly
> useful when reading core files. unfortunatly the translation is one-way,
> so if you are in the habit of editing core and feeding it back into ghc,
> you will be disapointed, but for the (more common?) case of reading core
> to determine what optimizations have been performed, this is quite nice.
> 
> you can also copy 
> haskell.vim to ~/.vim/syntax/ghc_core.vim 
> to get basic color syntax highlighting.
> 
> Is there a way to tell ghc to format core files assuming the screen is
> very wide? the code ends up in a small ribbon along the right side of
> the screen at pretty low nesting depths making it harder to read..
>         John
> 
> --- add to ~/.vim/filetype.vim
> 
> if exists("did_load_filetypes")
>     finish
> endif
> augroup filetypedetect
>     au! BufNewFile,BufRead *.hsc setfiletype haskell
>     au! BufNewFile,BufRead *.as setfiletype haskell
>     au! BufNewFile,BufRead *.pappy setfiletype haskell
>     au! BufNewFile,BufRead *.las setfiletype haskell
>     au! BufNewFile,BufRead *.hcr setfiletype ghc_core
> augroup END
> 
> --- ghc_core.vim, place in ~/.vim/ftplugins
> 
> if exists("s:loaded_ghc_core")
> 	finish
> endif
> let s:loaded_ghc_core = 1
> 
> augroup GhcCore
> 	autocmd BufReadPost *.hcr cal s:GhcCoretoUTF8()
> 	"autocmd BufWritePre *.hcr cal s:UTF8toGhcCore()
>        " autocmd BufWritePost *.hcr cal s:GhcCoretoUTF8()
> augroup END
> 
> function s:UTF8toGhcCore() 
>         " we can't do this reversably
> endfunction
> 
> function s:GhcCoretoUTF8()
> 
> 	silent %s/ZL/(/eg
> 	silent %s/ZR/)/eg
> 	silent %s/ZM/[/eg
> 	silent %s/ZN/]/eg
> 	silent %s/ZC/:/eg
> 	silent %s/ZZ/Z/eg
> 	silent %s/zz/z/eg 
> 	silent %s/za/&/eg 
> 	silent %s/zb/|/eg 
> 	silent %s/zc/^/eg 
> 	silent %s/zd/$/eg 
> 	silent %s/ze/=/eg 
> 	silent %s/zg/>/eg 
> 	silent %s/zh/#/eg 
> 	silent %s/zi/./eg 
> 	silent %s/zl/</eg 
> 	silent %s/zm/-/eg 
> 	silent %s/zn/!/eg 
> 	silent %s/zp/+/eg 
> 	silent %s/zq/'/eg 
> 	silent %s/zr/\\/eg 
> 	silent %s/zs/\//eg 
> 	silent %s/zt/*/eg 
> 	silent %s/zu/_/eg 
> 	silent %s/zv/%/eg 
> 	silent %s/Z0T/()/eg 
> 	silent %s/Z2T/(,)/eg 
> 	silent %s/Z3T/(,,)/eg 
> 	silent %s/Z4T/(,,,)/eg 
> 	silent %s/Z5T/(,,,,)/eg 
> 	silent %s/Z6T/(,,,,,)/eg 
> 	silent %s/Z1H/(# #)/eg 
> 	silent %s/Z2H/(#,#)/eg 
> 	silent %s/Z3H/(#,,#)/eg 
> 	silent %s/Z4H/(#,,,#)/eg 
> 	silent %s/Z5H/(#,,,,#)/eg 
> 	silent %s/Z6H/(#,,,,,#)/eg 
> 
>         " these are debatable, but make things less cluttered.
> 	silent %s/GHC\.Prim\.//eg 
> 	silent %s/GHC\.Base\.//eg 
> 	silent %s/GHC\.IOBase\.//eg 
> 
> endfunction
> 
> do GhcCore BufRead
> 
> -- 
> John Meacham - ???repetae.net???john??? 
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


More information about the Glasgow-haskell-users mailing list