12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758openResulttypecompletionsexternaladd_completion:completions->string->unit="ml_add_completion"externallinenoise:string->stringoption="ml_linenoise"externalhistory_add_:string->int="ml_history_add"externalhistory_set_:max_length:int->int="ml_history_set_maxlen"externalhistory_save_:filename:string->int="ml_history_save"externalhistory_load_:filename:string->int="ml_history_load"externalcatch_break:bool->unit="ml_catch_break"externalsetup_bridges:unit->unit="ml_setup_bridges"typehint_color=Red|Green|Yellow|Blue|Magenta|Cyan|Whiteletcompletion_cb=ref(fun__->())lethints_cb=ref(fun_->None)letset_completion_callback(f:string->completions->unit):unit=completion_cb:=f;Callback.register"lnoise_completion_cb"fletset_hints_callback(f:string->(string*hint_color*bool)option):unit=hints_cb:=f;Callback.register"lnoise_hints_cb"f(* initialization: register [Sys.Break] and enable catch-break *)let()=setup_bridges();set_completion_callback!completion_cb;set_hints_callback!hints_cb;Callback.register_exception"sys_break"Sys.Break;catch_breaktruelethistory_addh=ifhistory_add_h=0thenError"Couldn't add to history"elseOk()lethistory_set~max_length=ifhistory_set_~max_length=0thenError"Couldn't set the max length of history"elseOk()lethistory_save~filename=ifhistory_save_~filename=0thenOk()elseError"Couldn't save"lethistory_load~filename=ifhistory_load_~filename=0thenOk()elseError"Couldn't load the file"externalclear_screen:unit->unit="ml_clearscreen"externalset_multiline:bool->unit="ml_set_multiline"externalprint_keycodes:unit->unit="ml_printkeycodes"