Skip to content

Instantly share code, notes, and snippets.

@wchargin
Created January 7, 2016 14:12
Show Gist options
  • Save wchargin/8df54bbb1a24f36e78e9 to your computer and use it in GitHub Desktop.
Save wchargin/8df54bbb1a24f36e78e9 to your computer and use it in GitHub Desktop.
real-time Haskell expression-internal type inference
let g:airline_section_gutter = "%{MyStatuslineFunction()}%="
function! MyStatuslineFunction()
if &l:ft != "haskell"
return "nope"
else
let l:file = expand("%")
if l:file == ''
return ""
endif
if !filereadable(l:file)
return ""
endif
let l:line = line('.')
let l:col = col('.')
let l:cmd = hdevtools#build_command('type', shellescape(l:file) . ' ' . l:line . ' ' . l:col)
let l:output = system(l:cmd)
let l:types = []
for l:line in split(l:output, '\n')
let l:m = matchlist(l:line, '\(\d\+\) \(\d\+\) \(\d\+\) \(\d\+\) "\([^"]\+\)"')
call add(l:types, [l:m[1 : 4], l:m[5]])
endfor
return len(types) > 0 ? types[0][1] : "(no type)"
endif
endfunction
@wchargin
Copy link
Author

wchargin commented Jul 2, 2023

EnlightenedShimmeringHoiho.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment