This file contains 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 With_position = struct | |
type 'a t = | |
{ value : 'a | |
; pos : Lexing.position | |
} | |
end | |
type 'dict atom = | |
[ `Symbol of string | |
| `Vector of 't array |
This file contains 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
class type a_setter = object | |
method setter : unit | |
end | |
class type a_getter = object | |
method getter : unit | |
end | |
class type a_lens = object | |
inherit a_getter |
This file contains 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 van Laarhoven CPS lenses. https://gist.github.com/tel/08d2a94de21f483cbb20 | |
plus eta expansion | |
https://stackoverflow.com/questions/29187287/sneaking-lenses-and-cps-past-the-value-restriction | |
*) | |
type (-'s, +'t, +'a, -'b) _t = | |
{ op : 'r. ('a -> ('b -> 'r) -> 'r) -> ('s -> ('t -> 'r) -> 'r) } | |
type (-'s, +'t, +'a, -'b) t = unit -> ('s, 't, 'a, 'b) _t |
This file contains 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
#!r6rs | |
(library (binding) | |
(export bound?) | |
(import | |
(for (only (rnrs base) eq? list not quote lambda eqv? unquote quasiquote) expand) | |
(for (only (rnrs base) define-syntax) run) | |
(for (only (rnrs lists) exists) expand) | |
(for (only (rnrs syntax-case) | |
quasisyntax unsyntax | |
syntax-case syntax free-identifier=? syntax->datum datum->syntax) |
This file contains 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 TaggedInitial = struct | |
type _ t = | |
| Int : int -> int t | |
| Bool : bool -> bool t | |
| Eql : ('a t * 'a t) -> bool t | |
| If : (bool t * 'a t * 'a t) -> 'a t | |
let term = | |
If (Bool true, Int 42, Int 0) |
This file contains 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 Make() : sig | |
type field = .. | |
type 'a field_access = | |
{ get : field -> 'a option | |
; set : 'a -> field | |
; default : 'a | |
} | |
type t |
This file contains 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
object Main { | |
// 型クラスの定義 | |
trait Show[A] { | |
def show(x: A): String | |
} | |
// 型クラスのインスタンス: Int | |
implicit def ShowInt: Show[Int] = new Show[Int] { | |
def show(x: Int) = x.toString | |
} |
This file contains 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 type Show = sig | |
type t | |
val show : t -> string | |
end | |
module ShowInt : Show with type t = int = struct | |
type t = int | |
let show = Int.to_string | |
end |
This file contains 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
(use www.css) | |
(select-module www.css) | |
(define %an+b | |
(let () | |
(define %+ ($seq ($delim #\+) ($return +))) | |
(define %- ($seq ($delim #\-) ($return -))) | |
(define %opt-sign | |
($optional ($or %+ %-) +)) | |
(define %n ($match1 ('IDENT . 'n))) | |
(define %-n ($match1 ('IDENT . '-n))) |
This file contains 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 = | |
| Leaf of int * string | |
| Concat of int * t * t | |
let length = function | |
| Leaf (i, _) -> i | |
| Concat (i, _, _) -> i | |
let leaf s = | |
Leaf (String.length s, s) |