aboutsummaryrefslogtreecommitdiff
path: root/lib/kernel/citation.ml
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-11 11:37:32 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-11 11:37:32 +0200
commit57322e766a0ece579dafcddcfe2572676a98fca8 (patch)
tree0e6ca11d29000b956a2c4bb65e436b0eb9251809 /lib/kernel/citation.ml
parent270be2561ae440cea814566b74712750352e56e4 (diff)
downloadcolitur-57322e766a0ece579dafcddcfe2572676a98fca8.tar.gz
colitur-57322e766a0ece579dafcddcfe2572676a98fca8.zip
kernel: Names, Citation and Date_spec
Names is an open language-keyed assoc kept in canonical order so equal name sets serialise identically. Citation carries references only, never text. Date_spec ships the one form the EF sanctoral needs; 29 February is constructible and resolves to None in common years.
Diffstat (limited to 'lib/kernel/citation.ml')
-rw-r--r--lib/kernel/citation.ml33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/kernel/citation.ml b/lib/kernel/citation.ml
new file mode 100644
index 0000000..a819040
--- /dev/null
+++ b/lib/kernel/citation.ml
@@ -0,0 +1,33 @@
+(* Scripture references only -- never scripture text (spec ยง1: that is lectio's
+ job). *)
+type part = First | Psalm | Second | Gospel | Tract | Alleluia | Sequence
+[@@deriving sexp]
+
+let all_parts = [ First; Psalm; Second; Gospel; Tract; Alleluia; Sequence ]
+
+let part_to_string = function
+ | First -> "first" | Psalm -> "psalm" | Second -> "second" | Gospel -> "gospel"
+ | Tract -> "tract" | Alleluia -> "alleluia" | Sequence -> "sequence"
+
+let part_of_string = function
+ | "first" -> Some First | "psalm" -> Some Psalm | "second" -> Some Second
+ | "gospel" -> Some Gospel | "tract" -> Some Tract | "alleluia" -> Some Alleluia
+ | "sequence" -> Some Sequence | _ -> None
+
+type t = { part : part; reference : string }
+
+let sexp_of_t { part; reference } =
+ Sexplib0.Sexp.List [
+ Sexplib0.Sexp_conv.sexp_of_string "part";
+ sexp_of_part part;
+ Sexplib0.Sexp_conv.sexp_of_string "reference";
+ Sexplib0.Sexp_conv.sexp_of_string reference
+ ]
+
+let t_of_sexp sexp =
+ match sexp with
+ | Sexplib0.Sexp.List [ _; part_sexp; _; ref_sexp ] ->
+ let part = part_of_sexp part_sexp in
+ let reference = Sexplib0.Sexp_conv.string_of_sexp ref_sexp in
+ { part; reference }
+ | _ -> Sexplib0.Sexp_conv.of_sexp_error "Citation.t_of_sexp: expected record format" sexp