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
(* | |
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
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
type t = | |
| Pair of t * t | |
| Number of int | |
| Function of string (* or what? *) | |
let rec empty = Pair (empty, empty) (* make a looped value *) | |
let is_empty t = match t with | |
| Pair (t1, t2) -> t == t1 && t == t2 (* using pointer equality *) | |
| _ -> false |
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 Printf | |
module ByMonomorphicRecord = struct | |
(* Interface by a monomorphic record *) | |
type point = { | |
get : unit -> int; | |
set : int -> unit; | |
print : unit -> unit; | |
} |
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
(* | |
OCaml translation of the ideas explained in http://fumieval.hatenablog.com/entry/2014/09/22/144401 | |
To emulate the higher kinded polymorphism, the technique used explained in https://ocamllabs.github.io/higher/lightweight-higher-kinded-polymorphism.pdf | |
*) | |
module StateMonad = struct | |
type ('s, 'a) m = 's -> 's * 'a |
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
(* OCaml version | |
compile with: | |
ocamlopt str.cmxa -o classifyDigits classifyDigits.ml | |
*) | |
(* | |
// This F# dojo is directly inspired by the | |
// Digit Recognizer competition from Kaggle.com: | |
// http://www.kaggle.com/c/digit-recognizer | |
// The datasets below are simply shorter versions of |
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 () = | |
prerr_endline @@ GMain.Main.init (); | |
let window = GWindow.window ~title: "liv" ~allow_shrink: true ~allow_grow: true () in | |
window#show (); | |
window#event#add [`SCROLL]; | |
ignore @@ window#event#connect#scroll ~callback:(fun ev -> | |
Printf.eprintf "at +%.0f+%.0f %s\n%!" | |
(GdkEvent.Scroll.x ev) | |
(GdkEvent.Scroll.y ev) |
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
module Id = struct | |
let name = "pa_fun_fields" | |
let version = "1.0" | |
end | |
open Camlp4 | |
module Make (Syntax : Sig.Camlp4Syntax) = struct | |
include Syntax |
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 Spotlib.Spot | |
open GapiUtils.Infix | |
open GapiLens.Infix | |
open GapiLens.StateInfix | |
open GapiMonad.SessionM | |
module OAuth2 = GapiOAuth2 | |
module Conv = GapiConversation | |
module Service = GapiService |