Last active
December 9, 2016 02:50
-
-
Save KeenS/4325c302e8be1ef2e3146954a6dcfcac 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
_require "basis.smi" | |
_require "ffi.smi" | |
functor ReadLine_(X: sig val name: string end) = struct | |
val readline: string -> string | |
end |
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
functor ReadLine_(val name: string) = struct | |
val lib = DynamicLink.dlopen name | |
fun find s = DynamicLink.dlsym(lib, s) | |
val readline_ = find "readline": _import (string) -> char ptr | |
val readline = Pointer.importString o readline_ | |
end | |
structure ReadLine = ReadLine_(val name = "libreadline.so") | |
val () = print (ReadLine.readline "> ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment