module type T = sig type t val muted : t -> t val a : t val e : [`Closed | `Opened] -> t val eu : [`Closed | `Opened] -> t val o : [`Closed | `Opened] -> t val schwa : unit -> t val i : t val u : t val u' : t (** Create a diphtongue from a semi-voyel and a voyel *) val diphtongue: t -> t -> t val nasal: t -> t val none: t val p: t val b: t val t: t val d: t val k: t val g: t val f: t val s: unit -> t val sz: unit -> t val ch: unit -> t val z: unit -> t val n: t val m: t val r: unit -> t val l: unit -> t val semi_voyel_w: t val is_voyel : t -> bool val is_nasal : t -> bool type code = | None | SZ | Voyel_A | Voyel_I | Voyel_O | SemiVoyel_W | Diphtonge of code * code val code : t -> code end module T = struct type kind = | None | Voyel type code = | None | SZ | Voyel_A | Voyel_I | Voyel_O | SemiVoyel_W | Diphtonge of code * code type t = { code : code ; repr : string ; muted : bool ; kind : kind ; nasal : bool } end module Repr = struct let a = "a" and a_nasal = "@" and o = "o" and o_nasal = "§" and i = "i" and i_nasal = "5" and u = "y" and u' = "u" and p = "p" and b = "b" and t = "t" and d = "d" and k = "k" and g = "g" and f = "f" and ch = "S" and s = "s" and z = "z" and m = "m" and n = "n" and l = "L" and r = "R" and w = "w" end module S = struct include T let is_voyel t = t.kind = Voyel let is_nasal t = t.nasal let none = { repr = "" ; muted = false ; kind = None ; nasal = false ; code = None } let voyel = { none with kind = Voyel } let diphtongue v1 v2 = { voyel with repr = (v1.repr) ^ (v2.repr) ; code = Diphtonge (v1.code, v2.code) } let code t = t.code let a = { voyel with repr = Repr.a ; code = Voyel_A } let e = function | `Closed -> { voyel with repr = "e" } | `Opened -> { voyel with repr = "E" } let eu = function | `Closed -> { voyel with repr = "2" } | `Opened -> { voyel with repr = "9" } let schwa () = { voyel with repr = "°" } let o _ = { voyel with repr = Repr.o ; code = Voyel_O } let i = { voyel with repr = Repr.i ; code = Voyel_I } let u = { voyel with repr = Repr.u } let u' = { voyel with repr = Repr.u' } let p = { none with repr = Repr.p } let b = { none with repr = Repr.b } let t = { none with repr = Repr.t } let d = { none with repr = Repr.d } let k = { none with repr = Repr.k } let g = { none with repr = Repr.g } let f = { none with repr = Repr.f } let s () = { none with repr = Repr.s } let sz () = { (s()) with code = SZ } let ch () = { none with repr = Repr.ch } let z () = { none with repr = Repr.z } let n = { none with repr = Repr.n ; nasal = true } let m = { none with repr = Repr.m ; nasal = true } let l () = { none with repr = Repr.l } let r () = { none with repr = Repr.r } let semi_voyel_w = { none with repr = Repr.w ; code = SemiVoyel_W} let nasal t = match t.code with | Voyel_A -> { t with repr = Repr.a_nasal ; nasal = true } | Voyel_O -> { t with repr = Repr.o_nasal ; nasal = true } | Voyel_I -> { t with repr = Repr.i_nasal ; nasal = true } | Diphtonge (SemiVoyel_W, Voyel_A) -> diphtongue semi_voyel_w { t with repr = Repr.i_nasal ; nasal = true } | _ -> t let muted f = { none with repr = "(" ^ f.repr ^ ")" ; muted = true } end include S