Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,4 @@
|
|||
module type Eatable = sig
|
||||
type t
|
||||
val eat : t -> unit
|
||||
end
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
module MakeFoodBox(A : Eatable) = struct
|
||||
type elt = A.t
|
||||
type t = F of elt list
|
||||
let make_box_from_list xs = F xs
|
||||
end
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
type banana = Foo (* a dummy type *)
|
||||
|
||||
module Banana : Eatable with type t = banana = struct
|
||||
type t = banana
|
||||
let eat _ = print_endline "I'm eating a banana"
|
||||
end
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module EatFloat : Eatable with type t = float = struct
|
||||
type t = float
|
||||
let eat f = Printf.printf "I'm eating %f\n%!" f
|
||||
end
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
module BananaBox = MakeFoodBox (Banana)
|
||||
module FloatBox = MakeFoodBox (EatFloat)
|
||||
|
||||
let my_box = BananaBox.make_box_from_list [Foo]
|
||||
let your_box = FloatBox.make_box_from_list [2.3; 4.5]
|
||||
Loading…
Add table
Add a link
Reference in a new issue