Skip to content

Instantly share code, notes, and snippets.

@JasonGross
Created November 19, 2013 19:58
Show Gist options
  • Select an option

  • Save JasonGross/7551528 to your computer and use it in GitHub Desktop.

Select an option

Save JasonGross/7551528 to your computer and use it in GitHub Desktop.
Bad ocaml
let gen_const_list ~is_done:(is_done : 'n -> bool) ~pred:(pred : 'n -> 'n)
(size : 'n) (v : 'a) : 'a list =
let rec helper size v =
if is_done size then [] else v::(helper (pred size) v)
in helper size v
let const_list : int -> 'a -> 'a list =
gen_const_list ~is_done:(fun size -> size <= 0) ~pred:(fun n -> n - 1)
module Stupid = struct
type t = X | Y
let x (sz : int) : t list = const_list sz X
end;;
(** Error: This expression has type t but an expression was expected of type 'a
The type constructor t would escape its scope *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment