let (|-) g f x = f (g x)
-module Terminal : sig
+module Terminal :
+sig
type color = [ `green
| `red
| `white
val clear : unit -> unit
val reset : unit -> unit
-end = struct
+end =
+struct
type color = [ `green
| `red
| `white
end
-module type MATRIX = sig
- module Point : sig
+module Matrix :
+sig
+ module Point :
+ sig
type t = {r : int; k : int}
end
val iter : 'a t -> f:(Point.t -> 'a -> unit) -> unit
val print : 'a t -> to_string:('a -> string) -> unit
-end
-
-module Matrix : MATRIX = struct
- module Point = struct
+end =
+struct
+ module Point =
+ struct
type t = {r : int; k : int}
let (+) p p' =
}
end
- module Direction = struct
+ module Direction =
+ struct
type t = NW | N | NE
| W | E
| SW | S | SE
end
-module PhenoType : sig
+module PhenoType :
+sig
type t
val create : char -> Terminal.color option -> t
val to_string : t -> string
-end = struct
+end =
+struct
type t = { color : Terminal.color option
; character : char
}
end
-module Cell = struct
- module State = struct
+module Cell =
+struct
+ module State =
+ struct
type intention = Friendly
| Neutral
| Hostile
end
-module type RULE = sig
+module type RULE =
+sig
val create : unit -> Cell.t
val transition : self:Cell.State.t
end
-module Life : RULE = struct
- module State : sig
+module Life : RULE =
+struct
+ module State :
+ sig
type t = D | A
val of_int : int -> t
val to_cell : t -> Cell.t
val of_cell_state : Cell.State.t -> t
- end = struct
+ end =
+ struct
type t = D | A
let of_int = function
end
-module ForestFire : RULE = struct
- module State : sig
+module ForestFire : RULE =
+struct
+ module State :
+ sig
type t = E | T | B
val is_burning : t -> bool
val to_cell : t -> Cell.t
val of_cell_state : Cell.State.t -> t
- end = struct
+ end =
+ struct
type t = E | T | B
let is_burning = function
end
-module Automaton : sig
+module Automaton :
+sig
type t
val create : rows:int
-> t
val loop : t -> unit
-end = struct
+end =
+struct
type cell = { data : Cell.t
; rule : (module RULE)
}