summaryrefslogtreecommitdiff
path: root/src/lib/sounds
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-09-03 17:37:03 +0200
committerSébastien Dailly <sebastien@chimrod.com>2021-09-03 17:37:03 +0200
commit123c8bc693063cfc880709c7dfa700a177a66adb (patch)
tree5dd508c4ac5876fe80a661a4281b6fdaf3d064a9 /src/lib/sounds
parent48dc04c3b9afe19207d15b873452129d9c2b3b4c (diff)
Ended refactoring
Diffstat (limited to 'src/lib/sounds')
-rw-r--r--src/lib/sounds/repr.ml2
-rw-r--r--src/lib/sounds/repr.mli46
-rw-r--r--src/lib/sounds/sig.ml55
-rw-r--r--src/lib/sounds/sounds.ml14
-rw-r--r--src/lib/sounds/sounds.mli4
5 files changed, 68 insertions, 53 deletions
diff --git a/src/lib/sounds/repr.ml b/src/lib/sounds/repr.ml
index af13e68..72cf95d 100644
--- a/src/lib/sounds/repr.ml
+++ b/src/lib/sounds/repr.ml
@@ -1,5 +1,7 @@
type t = string
+let none = ""
+
let a = "a"
and a_nasal = "@"
diff --git a/src/lib/sounds/repr.mli b/src/lib/sounds/repr.mli
index 3e2a9c7..7e2e035 100644
--- a/src/lib/sounds/repr.mli
+++ b/src/lib/sounds/repr.mli
@@ -1,45 +1 @@
-type t = string
-
-val a : t
-val a_nasal : t
-
-val e_opened : t
-val e_closed : t
-val schwa : t
-
-val eu : t
-
-val o : t
-val o_nasal : t
-
-val i : t
-val i_nasal : t
-
-val y : t
-val y_nasal : t
-
-val u : t
-val p : t
-val b : t
-val t : t
-val d : t
-val k : t
-val g : t
-val f : t
-val v : t
-val ch : t
-val j : t
-val s : t
-val z : t
-val m : t
-val n : t
-val l : t
-val r : t
-
-val semi_voyel_w : t
-
-val semi_voyel_y : t
-
-val muted : t -> t
-
-val diphtongue : t -> t -> t
+include Sig.REPR with type t = String.t
diff --git a/src/lib/sounds/sig.ml b/src/lib/sounds/sig.ml
index 372b888..6b496d2 100644
--- a/src/lib/sounds/sig.ml
+++ b/src/lib/sounds/sig.ml
@@ -1,4 +1,55 @@
+module type REPR = sig
+ type t
+
+ val none: t
+
+ val a : t
+ val a_nasal : t
+
+ val e_opened : t
+ val e_closed : t
+ val schwa : t
+
+ val eu : t
+
+ val o : t
+ val o_nasal : t
+
+ val i : t
+ val i_nasal : t
+
+ val y : t
+ val y_nasal : t
+
+ val u : t
+ val p : t
+ val b : t
+ val t : t
+ val d : t
+ val k : t
+ val g : t
+ val f : t
+ val v : t
+ val ch : t
+ val j : t
+ val s : t
+ val z : t
+ val m : t
+ val n : t
+ val l : t
+ val r : t
+
+ val semi_voyel_w : t
+
+ val semi_voyel_y : t
+
+ val muted : t -> t
+
+ val diphtongue : t -> t -> t
+end
+
module type T = sig
+
type t
val muted : t -> t
@@ -66,6 +117,8 @@ module type T = sig
val is_voyel : t -> bool
val is_nasal : t -> bool
- val repr : t -> string
+ val repr
+ : (module REPR with type t = 'a) -> t -> 'a
end
+
diff --git a/src/lib/sounds/sounds.ml b/src/lib/sounds/sounds.ml
index 92a644f..e5f5d29 100644
--- a/src/lib/sounds/sounds.ml
+++ b/src/lib/sounds/sounds.ml
@@ -1,4 +1,5 @@
module Sig = Sig
+module Repr = Repr
type kind =
| None
@@ -239,14 +240,15 @@ let muted f =
code = Muted f }
let rec repr
- : t -> Repr.t
- = fun letter ->
+ : type a. (module Sig.REPR with type t = a) -> t -> a
+ = fun m letter ->
+ let module Repr = (val m:Sig.REPR with type t = a) in
match letter.code, letter.nasal with
- | None, _ -> ""
+ | None, _ -> Repr.none
| Voyel_A, false -> Repr.a
| Voyel_A, true -> Repr.a_nasal
- | Voyel_AI, false -> "E"
+ | Voyel_AI, false -> Repr.e_opened
| Voyel_AI, true -> Repr.i_nasal
| E_Closed, _ -> Repr.e_closed
| E_Opened, true | Voyel_E, true -> Repr.a_nasal
@@ -283,5 +285,5 @@ let rec repr
| Consonant_N, _ -> Repr.n
| Consonant_L, _ -> Repr.l
| Consonant_R, _ -> Repr.r
- | Diphtonge (l1, l2), _ -> Repr.diphtongue (repr l1) (repr l2)
- | Muted t, _ -> Repr.muted (repr t)
+ | Diphtonge (l1, l2), _ -> Repr.diphtongue (repr m l1) (repr m l2)
+ | Muted t, _ -> Repr.muted (repr m t)
diff --git a/src/lib/sounds/sounds.mli b/src/lib/sounds/sounds.mli
index acb3335..8a07db3 100644
--- a/src/lib/sounds/sounds.mli
+++ b/src/lib/sounds/sounds.mli
@@ -1,4 +1,5 @@
module Sig = Sig
+module Repr = Repr
type t
val muted : t -> t
@@ -67,4 +68,5 @@ val semi_voyel_y: t
val is_voyel : t -> bool
val is_nasal : t -> bool
-val repr : t -> string
+val repr
+ : (module Sig.REPR with type t = 'a) -> t -> 'a