Skip to content

Instantly share code, notes, and snippets.

@nomaddo
nomaddo / f.ml
Created February 14, 2014 09:26
type annotation
(* これは通らない *)
let f x =
let (g:'a) = fun y -> y
g 1; g "str"
(* これは通る *)
let f x =
let g = fun y -> y
g 1; g "str"
@nomaddo
nomaddo / f.sml
Created October 12, 2014 15:30
description
fun f x = let ... x :: nil ...
... Array.update(a, i, x) ...
in (x, x) end
fun g y = f (y, 3.14)
(* f : 'a -> 'a * 'a *)
(* g : 'b -> (b * real) * ('b * real) *)
@nomaddo
nomaddo / ::1.ml
Last active August 29, 2015 14:08
unit1
# type t = :: of int * float;;
type t = :: of int * float
# 1 :: 1.1;;
- : t = :: (1, 1.1)
# 1 :: [];;
Characters 5-7:
1 :: [];;
^^
Error: This expression has type 'a list
@nomaddo
nomaddo / unit1.ml
Created November 5, 2014 11:20
unit1.ml
# type t = () of unit;;
type t = () of unit
# () ();;
- : t = () ()
@nomaddo
nomaddo / unit2.ml
Created November 5, 2014 11:21
unit2.ml
# type 'a t = () of 'a;;
type 'a t = () of 'a
# () 12;;
- : int t = () 12
# () ();;
Characters 3-5:
() ();;
^^
Error: The constructor () expects 1 argument(s),
but is applied here to 0 argument(s)
@nomaddo
nomaddo / unit3.ml
Created November 5, 2014 11:21
unit3.ml
# module M = struct type t = () end;;;;;
module M : sig type t = () end
# M.();;
Characters 3-4:
M.();;
^
Error: Syntax error: operator expected.
# M.(());;
- : M.t = M.()
@nomaddo
nomaddo / ::1.ml
Created November 5, 2014 11:22
::1
# type t = :: of int * float;;
type t = :: of int * float
# 1 :: 1.1;;
- : t = :: (1, 1.1)
# 1 :: [];;
Characters 5-7:
1 :: [];;
^^
Error: This expression has type 'a list
@nomaddo
nomaddo / ::2.ml
Created November 5, 2014 11:22
::2.ml
# type 'a t = :: of 'a t * 'a t | Leaf of 'a;;
type 'a t = :: of 'a t * 'a t | Leaf of 'a
# Leaf 1 :: Leaf 2 :: Leaf 3;;
- : int t = :: (Leaf 1, :: (Leaf 2, Leaf 3))
@nomaddo
nomaddo / dot.ml
Created November 5, 2014 11:22
dot.ml
# List.(map succ [1;2;3]);;
- : int list = [2; 3; 4]
# List.(M.(()));;
- : M.t = M.()
@nomaddo
nomaddo / true.ml
Created November 5, 2014 11:31
true.ml
# type t = true of bool;;
type t = true of bool
# true true;;
- : t = true true
# type 'a t = true of 'a
;;
type 'a t = true of 'a
# true true;;
Characters 5-9:
true true;;