wuub / SublimeREPL

SublimeREPL - run an interpreter inside ST2 (Clojure, CoffeeScript, F#, Groovy, Haskell, Lua, MozRepl, NodeJS, Python, R, Ruby, Scala, shell or configure one yourself)
https://github.com/wuub/SublimeREPL
Other
2.14k stars 312 forks source link

OCaml utop freezed upon decimal entry. #501

Open scawa1952 opened 7 years ago

scawa1952 commented 7 years ago

I am going through the "Real World OCaml: Functional Programing for the Masses" book. I have set up utop to run in Sublime Text 3 using SublimeREPL on a MacBook Pro OX 10.12.2 Sierra

I installed OCaml through Brew. Upon Startup of SublimeREPL -> OCaml -> utop I get:

Welcome to utop version 1.19.3 (using OCaml version 4.04.0)!

Findlib has been successfully loaded. Additional directives:

require "package";; to load a package

list;; to list the available packages

camlp4o;; to load camlp4 (standard syntax)

camlp4r;; to load camlp4 (revised syntax)

predicates "p,q,...";; to set these predicates

Topfind.reset();; to force that packages will be reloaded

thread;; to enable threads

utop was built without camlp4 support.

If I enter the following:

open Core.Std;;

let another_tuple = ( 3, "four", 5.

It hangs upon entering the decimal point after 5

This does not happen when I go to utop via the terminal. And it does not happen when I use SublimeREPL OcCaml -> toplevel.

Any clues?

ssgam commented 5 years ago

hi,

following Real World OCaml as well ;-) got stuck at:

let pi = acos(-1.)

in case anybody is still interested ... found a workaround ...

i'm using:

MacOS Mojava (10.14) oCaml: 4.06.1 utop:2.2.0 opam: 2.0.2 sublimetext 3.3.1, build 3176

i had to removed auto_complete_triggers settings where they are defined:

  1. SublimeText > Preferences > Settings:
    "auto_complete_triggers":
    [
        {
            "characters": "<",
            "selector": "text.html"
        },
        {
            "characters": ".",
            "selector": "source.js"
        },
        {
            "characters": "\\",
            "selector": "text.tex.latex"
        },
//        {
//            "characters": ".",
//            "selector": "source.ocaml"
//        }
    ],
  1. $HOME/Library/Application Support/Sublime Text 3/Packages/SublimeREPL/config/OCaml/OCaml\ (toplevel).sublime-settings

    although this is really for OCaml's toplevel, decided to removed it as well...

    {
    //  "auto_complete_triggers": [ {"selector": "source.ocaml", "characters": "."} ]
    } 

This obviously removes the code completion suggestions that would be triggered by the "." character, that is available in utop in terminals ... (if it had worked ...)

however, i usually disable code completions for my other REPL'ed languages, as the popup windows, obscure the code under the popups ... so no love lost ;-)

As part of this bug hunt, i also:

A. amended the file: $HOME//Library/Application\ Support/Sublime\ Text\ 3/Packages/SublimeREPL/config/OCaml/Main.sublime-menu

a. replaced the values for the extend_env properties, with the outputs from the following command:

      opam config env | egrep 'CAML_LD_LIBRARY_PATH|OCAML_TOPLEVEL_PATH'

did this for both the toplevel and utop sections.

b. set the cmd_postfix property to :";;\n" this automatically insert the required ";;" when typing code in REPL.

B. created and added the following lines into $HOME/.ocamlinit :

   #use "topfind"
   #require "core.top";;
   open Core
Welcome to utop version 2.2.0 (using OCaml version 4.06.1)!

Findlib has been successfully loaded. Additional directives:
  #require "package";;      to load a package
  #list;;                   to list the available packages
  #camlp4o;;                to load camlp4 (standard syntax)
  #camlp4r;;                to load camlp4 (revised syntax)
  #predicates "p,q,...";;   to set these predicates
  Topfind.reset();;         to force that packages will be reloaded
  #thread;;                 to enable threads

# 1.0 /. 2.0;;

- : float = 0.5
#