idris-vimscript icon indicating copy to clipboard operation
idris-vimscript copied to clipboard

Annotate generated functions with original names

Open mrkgnao opened this issue 7 years ago • 3 comments

Currently, the code generator outputs Vim functions with horribly long names, leading to code like

function! s:Idris_PreludeziInterfacesziPreludeziShowziz40UPreludeziInterfacesziOrdzdPrecZCznzgzeZC0_2(a,b)
    let l:c = s:Idris_PreludeziInterfacesziPreludeziShowziz40UPreludeziInterfacesziOrdzdPrecZCzncompareZC0_2(a:a,a:b)
    if l:c[0] == 2
        let l:c = [1]
    else
    <snip>

It would be nice if a LineComment could be inserted before every function declaration annotating it with the original, un-mangled name that the Idris elaborator gives us. For instance, something like

" original name: io_bind
function! s:Idris_iozubind_6(a,b,c,d,e,f)
    let l:g = s:Idris_z7bUiozubindzu2z7dU_6(a:a,a:b,a:c,a:d,a:e,a:f)
    let l:h = s:Idris_z7bUAPPLYzu0z7dU_2(a:d,a:f)
    return s:Idris_z7bUAPPLYzu0z7dU_2(l:g,l:h)
endfunction

would be great.

This would entail either passing around the original names in addition to the mangled names produced by the vimName function, or decoding the mangled names after code generation.

The former is technically better and easier to extend (with, e.g. source locations) later, but will (as far as I can tell) involve a fair amount of refactoring to do the "passing around" of source information.

The latter is simpler, and should be easy to achieve. The decoding algorithm can be found here:

https://hackage.haskell.org/package/zenc-0.1.1/docs/src/Text-Encoding-Z.html

(That's where I copied the code in IRTS.CodegenVim.Internal.ZEncoding from.)

mrkgnao avatar Dec 04 '17 12:12 mrkgnao

Can you, please, provide a little more detail on this?

Thanks!

adicirstei avatar Dec 08 '17 12:12 adicirstei

@adicirstei done (check the first comment in this thread).

Note that, if you're looking for issues to fix, https://github.com/owickstrom/idris-vimscript/issues/7 is probably an even better first issue than this.

mrkgnao avatar Dec 08 '17 13:12 mrkgnao

Thanks, @mrkgnao ! I'll have a look.

Cheers!

adicirstei avatar Dec 08 '17 14:12 adicirstei