Giter Site home page Giter Site logo

tryocaml's People

Contributors

altgr avatar cagdasbozman avatar gasche avatar hammer avatar joaosa avatar lefessan avatar mkoconnor avatar mrshu avatar rixed avatar samoht avatar thelema avatar thomashuet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tryocaml's Issues

Error with GADTs and/or floating point values

result in the following code is nan in the tryocaml toplevel but 2.0 (as expected) in a standard OCaml installation:

type _ t =
    Int : int -> int t
  | Float : float -> float t
  | AddIF : (int -> float -> float) t
  | App : ('b -> 'a) t * 'b t -> 'a t

let rec eval : type a. a t -> a = function
  | Int n -> n
  | Float f -> f
  | AddIF -> (fun i f -> float i +. f)
  | App (f, x) -> (eval f) (eval x)

let result = eval (App (App (AddIF, Int 1), Float 1.0))

I came across this while experimenting with the GADT examples in the OCaml manual.

Ocaml does not work with negative numbers

Whats up with this??

Thanks!!!!

let x = -1.0;;

File "", line 1, characters 9-12:
Error: This expression has type float but an expression was expected of type
int

let x = 1.0;;

val x : float = 1.

Incorrectly Terminated Function Definition

When defining functions that span more than one line and manually hitting Enter on Try Ocaml website, the online toplevel will automatically add semicolon ending. In such situations this is undesirable behavior because my function definition is yet to be continued on the next line.

Example:
When you type the first line of Lesson 4 Step 1 into toplevel and hit Enter, the statement will be automatically ended (notice the undesirable semicolon below) and executed, and thus caused errors:

let string_of_int x = match w with;;

Characters 34-36:
Error: Syntax error

Here's Lesson 4 Step 1 function:
let string_of_int x = match x with
| 0 -> "zero"
| 1 -> "one"
| 2 -> "two"
| _ -> "many"

console

From time to time, it can be useful to have a console to interact with OCaml programs:

  • when there is a lot of data displayed
  • when the user is supposed to interact with the program (read_line, etc...)

Breaks phrases at random places

To reproduce:
Take clean http://try.ocamlpro.com/
Paste the following, line by line:
let f x = x x;;
let f x = (x, x);;
let c f = fun x -> f (f x);;
c f;;
let g x = f (f x);;
type r = {fu : 'a . 'a -> 'a};;

Then type the following line by hand, one by one character:

let c r = fun x -> r.fu (r.fu x);;

Press enter and we get errors from 3 separate chunks. Feels like extra ";;" are inserted randomly.
What we see at the end (see below) doesn't contain the last line as it was entered - it is changed in place.

.................
val g : 'a -> ('a * 'a) * ('a * 'a) = <fun>
# type r = {fu : 'a . 'a -> 'a};;
type r = { fu : 'a. 'a -> 'a; }
# let c r = fun x
File "", line 1, characters 13-14:
Error: Syntax error
#  -> 
File "", line 1, characters 16-18:
Error: Syntax error
# r.fu (r.fu x);;
File "", line 1, characters 19-20:
Error: Unbound value r

read_string / read_line

Tryocaml provides a read_string function

read_string ();;

  • : string = "jsjsjsf"

but there is no such function in Pervasives. I don't know if this is intentional.

There is instead a function read_line in Pervasives, and tryocaml knows about it,

read_line;;

  • : unit -> string =

but it fails:

read_line();;

Exception: ReferenceError: caml_ml_input_scan_line is not defined.

Note: the message "Enter your answer" when prompted for standard input is misleading. "Enter some integer" (for read_int), "Enter some string" (for read_line), etc. or simply "Standard input" would be more suited.

Jean-Christophe

Cannot build with ocaml 4.00

Cannot build from source using OCaml 4.00, neither using opam: there are a lot of cmi libs that cannot be used.

is_capital function in lesson 4

I got this in the terminal of Try OCaml :
is_capital 'a' ==> Exception: Failure "Not a valid letter".
is_capital 't' ==> Exception: Failure "Not a valid letter".

Instead, I would expect :
is_capital 'a' ==> - : bool = false
is_capital 't' ==> - : bool = false

It seems that is_capital provides the wrong result only with 'a' .. 'z' characters.
I reseted the terminal and retried, I got the same problem.

Thank you for your website.

incomplete parsing of input

I am getting spurious syntax errors, because apparently the parsing sometimes only takes part of my input, sometimes cutting in the middle of a word. Maybe some flush is missing somewhere ? However, the history remembers the input correctly.

I am using firefox 10.0.3 and the online version of tryocaml.

Thanks for the nice work, still. My adaptation Try RTT is almost ready ! (but the lack of support for recursive modules in js_of_ocaml troubles me).

we should minify the generated javascript files

Github algorithm to detect generated javascript file is described here:

https://github.com/github/linguist/blob/master/lib/linguist/blob_helper.rb#L266

it is based on the average_line_lenght which should be greated than 100. In this case, it will not count the file when he does file statistics and it will not display it in commit messages. A good consequence is that the project will become listed in the OCaml projects instead of in the JavaScript ones.

support `open_in` with an URL argument

The (very real) use case is a desperate university student with no computer at home, and only access to a public computer in his or her school's library, severely restricted (basic Caml installation, no right to install additional libraries or basically write any file on the computer), willing to work on image manipulation in OCaml.

The following could work in TryOCaml:

let image = open_in_bin "http://orion.math.iastate.edu/burkardt/data/bmp/snail.bmp";;
(* then use parsing code from http://pauillac.inria.fr/~cheno/lettre/lettre1.html *)

Current (incorrect) output:

Exception:
Sys_error
 "http://orion.math.iastate.edu/burkardt/data/bmp/snail.bmp: no such file or directory".

Full-screen mode

It would be nice to be able to have the console in full-screen mode

Function doesn't behave appropriately

This function in Lesson 4 Step 4:

let second_element = function
| [] -> failwith "the list is empty"
| [_] -> failwith "the list contains only one element"
| ::e:: -> e

throws a "the list contains only one element" exception for every list of size 1 or greater.

tryocaml cannot build on a 32 bits OCaml

The offending code is in ocaml-num/nat.ml:

let num_leading_zero_bits_in_digit nat int =
  let d = ref nat.(int) in
  let n = ref length_of_digit in
  if !d land 0xFFFF0000 <> 0 then (n := !n - 16; d := !d lsr 16);
  if !d land 0xFF00 <> 0 then (n := !n - 8; d := !d lsr 8);
  if !d land 0xF0 <> 0 then (n := !n - 4; d := !d lsr 4);
  if !d land 0xC <> 0 then (n := !n - 2; d := !d lsr 2);
  if !d land 0x2 <> 0 then (n := !n - 1; d := !d lsr 1);
  !n - !d

The first literal, 0xFFFF0000, provokes a compile-time failure on 32bits OCaml version.

Add flags to select language

The flags should change the URL (and thus, reset the terminal). Maybe add a cookie to save the language too.
It is different from set_lang "fr" that only changes the current language.

Cannot build: cmicomp rely on /usr/bin/ocamlrun

If one installed ocaml elsewhere than in /usr, then make fails with:

make[1]: Entering directory `/home/rixed/src/tryocaml/cmicomp'
cp -f ../js_of_ocaml/lib/*.cmi .
cp -f ../js_of_ocaml/lib/js_of_ocaml.cma .
./cmicomp -without-log CSS.cmi event_arrows.cmi js.cmi typed_array.cmi dom.cmi file.cmi json.cmi url.cmi dom_events.cmi firebug.cmi lwt_js.cmi webGL.cmi dom_html.cmi form.cmi regexp.cmi xmlHttpRequest.cmi
make[1]: ./cmicomp: Command not found

because cmicomp dashbang rely on /usr/bin/ocamlrun.

When building from sources, can't cmicomp be recompiled instead.?

add an editor window

A very simple textarea where to write text, and a button to push the text into the terminal, and another button to download the text.

Issue with firefox 9.0

I was going through lesson 20, and I noticed this weird pattern. I'm clicking through the pieces of code on the left, which are sent to the toplevel on the right. Everything is fine until I reach to "type 'a t = Leaf of 'a | Node of ('a * 'a) t". I need to click three times before the toplevel accepts its. The first two times, it reports a syntax error, even though there is none. See excerpt from the session below. I can consistently reproduce the issue with firefox 9.0, but the issue doesn't show up on chromium.

# let f : 'a -> 'a = function x -> x + 1;;
val f : int -> int = <fun>
# let f : 'a.'a -> 'a = function x -> x + 1;;
Characters 22-41:
Error: This definition has type int -> int which is less general than
         'a. 'a -> 'a
# type 'a t = Leaf of 'a | Node of ('a * 'a) t;;
Characters 11-12:
Error: Syntax error
# type 'a t = Leaf of 'a | Node of ('a * 'a) t;;
Characters 25-29:
Error: Syntax error
# type 'a t = Leaf of 'a | Node of ('a * 'a) t;;
type 'a t = Leaf of 'a | Node of ('a * 'a) t

input_line is not defined

We need something like input_line for interactive examples, where some OCaml code needs to ask the user to enter a value.

alternative sizes of terminal

The current size of the terminal fits well courses, but for longer sessions, it might be useful to have a bigger terminal (with more lines, maybe more columns too).

save sessions

It would be nice to get the log of everything that was typed in the toplevel, maybe even get the session log too (i.e. only the input, and both the input and output).

Add a Changelog/News

There should be a ChangeLog on the start page to display some news:

  • when new lessons are added
  • when new features are added
  • when the ocaml version has changed

exception Not_found during init

When opening try.ocamlpro.com, a box opens and tells me "exception Not_found during init" (though everything seems to work).

The same happens for /js_of_ocaml/

I'm using Iceweasel 23.0.1 on a Debian sid system.

Function doesn't behave appropriately

This function in Lesson 4, Step 4:

let second_element = function
| [] -> failwith "the list is empty"
| [_] -> failwith "the list contains only one element"
| ::e:: -> e

throws a "the list contains only one element" exception for every list of size 1 or greater.

longer lines

It would be nice to have the possibility to increase the length of the lines in the toplevel. It would be even better if we could set the size with a command in the toplevel, and a button to increase/decrease it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.