From ce139f1f2ee9903f6a1447e298da831acc4af9d1 Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Sat, 28 Sep 2013 15:29:14 -0400 Subject: [PATCH] Moved Terminal module to the top. So it can be visible from more modules. --- polymorphism/001/src/polymorphism.ml | 66 ++++++++++++++-------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/polymorphism/001/src/polymorphism.ml b/polymorphism/001/src/polymorphism.ml index cb65462..0f15a3a 100644 --- a/polymorphism/001/src/polymorphism.ml +++ b/polymorphism/001/src/polymorphism.ml @@ -1,6 +1,39 @@ open Core.Std +module Terminal : sig + type color = [ `green + | `red + ] + + val string_with_color : string -> color -> string + + val clear : unit -> unit + + val reset : unit -> unit +end = struct + type color = [ `green + | `red + ] + + let ansi_code_clear = "\027[2J" (* Clear screen *) + let ansi_code_reset = "\027[1;1H" (* Reset cursor position *) + + let string_of_color = function + | `green -> "\027[0;32m" + | `red -> "\027[1;31m" + + let string_with_color s c = + sprintf "%s%s\027[0m" (string_of_color c) s + + let clear () = + print_string ansi_code_clear + + let reset () = + print_string ansi_code_reset +end + + module type MATRIX = sig module Point : sig type t = {r : int; k : int} @@ -197,39 +230,6 @@ module Conway : RULE = struct end -module Terminal : sig - type color = [ `green - | `red - ] - - val string_with_color : string -> color -> string - - val clear : unit -> unit - - val reset : unit -> unit -end = struct - type color = [ `green - | `red - ] - - let ansi_code_clear = "\027[2J" (* Clear screen *) - let ansi_code_reset = "\027[1;1H" (* Reset cursor position *) - - let string_of_color = function - | `green -> "\027[0;32m" - | `red -> "\027[1;31m" - - let string_with_color s c = - sprintf "%s%s\027[0m" (string_of_color c) s - - let clear () = - print_string ansi_code_clear - - let reset () = - print_string ansi_code_reset -end - - module Automaton : sig type t -- 2.20.1