About the Lexeme thing, I think you misunderstood me – Lexemes are a type of Entity the same way Properties and Items are. I think Lexemes break the parametric polymorphism you are describing, as they do not share most fields with Items and Properties. For example, as Lexemes represent a word in a specific language and writing system they don’t have multilingual labels and instead have lemmas, usually in just one language. If I have
type 'a value
type 'a entity
type item
type property
type lexeme
module Item : sig
type t = item entity value
val label : t -> lang -> string
end
module Property: sig
type t = property entity value
val label : t -> lang -> string
end
module Lexeme : sig
type t = lexeme entity value
val lemmas: t -> (lang * string) list
end
Then, if I understand correctly, there’s no way to make a function that takes an Entity and a lang and returns the Entity’s label if it’s an Item or Property and the Entity’s first lemma string if it’s a Lexeme.
I guess this could be solved with something like
type entity_var =
| Item of item entity value
| Property of property entity value
| Lexeme of lexeme entity value
But I think that might defeat the purpose.