Skip to content

Instantly share code, notes, and snippets.

@nomaddo
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nomaddo/e7682796abe03f9021e1 to your computer and use it in GitHub Desktop.
Save nomaddo/e7682796abe03f9021e1 to your computer and use it in GitHub Desktop.
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
but an expression was expected of type float
# 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))
# List.(map succ [1;2;3]);;
- : int list = [2; 3; 4]
# List.(M.(()));;
- : M.t = M.()
# type t = true of bool;;
type t = true of bool
# true true;;
- : t = true true
# if true then 1 else 2;;
- : int = 1
# type t = () of unit;;
type t = () of unit
# () ();;
- : t = () ()
# 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)
# () (():unit);;
- : unit t = () ()
# module M () = struct end;;
module M : functor () -> sig end
# 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.()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment