Implemented OCaml mode for Ace

This commit is contained in:
Sergi Mansilla 2011-04-29 15:16:04 +02:00
commit 60f8f1b6a2
4 changed files with 486 additions and 0 deletions

View file

@ -26,6 +26,7 @@
<option value="csharp">C# Document</option>
<option value="c_cpp">C++ Document</option>
<option value="svg">SVG Document</option>
<option value="ocaml">OCaml Document</option>
<option value="textile">Textile Document</option>
<option value="plain">Text Document</option>
</select>
@ -99,6 +100,7 @@
<option value="c_cpp">C/C++</option>
<option value="coffee">CoffeeScript</option>
<option value="perl">Perl</option>
<option value="ocaml">OCaml</option>
<option value="csharp">C-Sharp</option>
<option value="svg">SVG</option>
<option value="textile">Textile</option>
@ -335,6 +337,26 @@ print "\n";
</script>
<script type="text/editor" id="ocamltext">(*
* Example of early return implementation taken from
* http://ocaml.janestreet.com/?q=node/91
*)
let with_return (type t) (f : _ -> t) =
let module M =
struct exception Return of t end
in
let return = { return = (fun x -> raise (M.Return x)); } in
try f return with M.Return x -> x
(* Function that uses the 'early return' functionality provided by `with_return` *)
let sum_until_first_negative list =
with_return (fun r ->
List.fold list ~init:0 ~f:(fun acc x ->
if x >= 0 then acc + x else r.return acc))
</script>
<script type="text/editor" id="svgtext"><svg
width="800" height="600"
xmlns="http://www.w3.org/2000/svg"