-
-
Save ben-x9/02272b76bb2dd6490ca75d05cdecab03 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
# Works with merlin version 2.5.4. Using protocol described at | |
# https://github.com/ocaml/merlin/blob/master/doc/dev/OLD-PROTOCOL.md#type-checking | |
usage () | |
{ | |
echo | |
echo Generate a signature for a Bucklescript module. | |
echo | |
echo Run this script from the root directory of the project, | |
echo passing in the module name. | |
echo | |
echo e.g: sig My_module | |
echo | |
echo For Reason pipe the output to: | |
echo refmt --parse ml --print re --interface true | |
echo | |
echo 'e.g: sig MyModule | refmt --parse ml --print re --interface true' | |
echo | |
exit 1 | |
} | |
[ -z "$1" ] && usage | |
mkdir -p ~/.tmp | |
it=~/.tmp/it | |
echo '["checkout","auto","."]["type","expression","'$1'","at","end"]' >$it | |
echo '["type","expression","'$1'","at","end"]' >>$it | |
ocamlmerlin <$it | sed -e '1d' -e '2d' -e 's/^\["return","sig *//' -e 's/ *end"\]$//' -e 's/\\"/"/g' -e 's/\\n/\ | |
/g' | sed -e '/^ *$/d' -e 's/^ //' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment