-
-
Save yawaramin/b86557ae81cbd019fcb9e071abe594de to your computer and use it in GitHub Desktop.
Bourne Shell script to print out Merlin's inferred signature of an OCaml file (module)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env sh | |
| usage () | |
| { | |
| echo Usage: all of the following will work: | |
| echo | |
| echo ML syntax: | |
| echo ' sig module.ml' | |
| echo ' sig module.mli' | |
| echo RE syntax: | |
| echo ' sig module.re' | |
| echo ' sig module.rei' | |
| exit 1 | |
| } | |
| [ -z "$1" ] && usage | |
| it=~/tmp/it | |
| touch $it | |
| echo '["tell","start","end","module It = struct' >$it | |
| sed 's/"/\\"/g' ${1%i} >>$it | |
| echo ' end let () = ()"]' >>$it | |
| echo '["type","expression","It","at","end"]' >>$it | |
| ocamlmerlin <$it | sed -e '/^\["return",true\]$/d' -e 's/^\["return","//' -e 's/"\]$//' -e 's/\\"/"/g' -e 's/\\n/\ | |
| /g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment