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
let (&) = (@@) | |
module Array = struct | |
include Array | |
let fold_lefti f st a = | |
let st = ref st in | |
Array.iteri (fun i a -> st := f !st i a) a; | |
!st | |
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
(* | |
ocamlfind ocamlopt -o recrec -package compiler-libs.common -linkpkg recrec.ml | |
*) | |
open List | |
open Format | |
let (&) = (@@) | |
module I() = TypedtreeIter.MakeIterator(struct |
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
diff --git a/README_curried_constr.md b/README_curried_constr.md | |
new file mode 100644 | |
index 0000000..12ed175 | |
--- /dev/null | |
+++ b/README_curried_constr.md | |
@@ -0,0 +1,66 @@ | |
+Variant constructors as functions | |
+================================== | |
+ | |
+Suppose we have: |
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
open Format | |
let rec hovb ppf = function | |
| 0 -> () | |
| n -> | |
fprintf ppf "(@[<hov>-----------------------------------%03d@," n; | |
hovb ppf (n-1); | |
fprintf ppf "@])" | |
let rec b ppf = function |
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
let rec fib = function | 0 -> 0 | 1 -> 1 | n -> fib (n-1) + fib (n-2) | |
(* Output of -dlambda *) | |
(setglobal Fib! | |
(letrec | |
(fib/1008 | |
(function n/1009 | |
(if (!= n/1009 0) | |
(if (!= n/1009 1) |
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
(let | |
((Fib/0 | |
(let* | |
((fib/1008 | |
(lambda (n/1009) | |
(if (not (equal n/1009 0)) | |
(if (not(equal n/1009 1)) | |
(+ (funcall fib/1008 (- n/1009 1)) (funcall fib/1008 (- n/1009 2))) | |
1) | |
0)))) |
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
match x with | |
| OpeExp (e1, op, e2) -> | |
begin match op with | |
| Plus -> ... | |
| Minus -> ... | |
end | |
| Root (e1, e2) -> ... |
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
(** Generation of typerep methods for tag-checking *) | |
(* XXX simply moved to sig.ml ? *) | |
open Typerep_lib.Std | |
module Sig = struct | |
open Sig | |
type res = [%import: Sig.res] | |
and ftypekind = [%import: Sig.ftypekind] |
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
hahaha |
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
let () = | |
ignore @@ GMain.Main.init (); | |
let window = GWindow.window ~width:100 ~height:100 () in | |
ignore @@ window#event#connect#configure ~callback:(fun ev -> | |
let open GdkEvent.Configure in | |
prerr_endline (Printf.sprintf "Configure %dx%d+%d+%d" | |
(width ev) | |
(height ev) | |
(x ev) | |
(y ev)); |