[@@deriving sexp] relies on sexp_of_* and *_of_sexp being defined already. Since they don’t, you would need to define them yourself. I think in this case it would look like:
type lexing_position = Lexing.position
let sexp_of_lexing_position position = fill in function here ...
let lexing_position_of_sexp sexp = fill in function here ...
In this case, the representation of Lexing.position is exposed, so I think you should be able to copy that representation and then do [@@deriving] as normal.
Edit: that is:
type lexing_position = Lexing.position =
{ pos_fname : string
; pos_lnum : int
; pos_bol : int
; pos_cnum : int
}
[@@deriving sexp]