Baffled by this compile error:

Minimal code:


open Sexplib

module Data_Util = struct

  module My_Sexp = struct

    exception Head_Of_Type_Not_Atom of Src_pos.Relative.t;;
    exception No_Data;;

    type t =
      | My_Atom of Src_pos.Relative.t * string
      | My_List of Src_pos.Relative.t * (t list);;


    let sexp_with_layout__to__t (v: Sexp_with_layout.t) : t  =
      match v with
        | Atom (sloc, s, _) -> My_Atom sloc s
        | List (sloc, lst, _) -> My_List sloc (List.map sexp_with_layout__to__t lst)
    ;;


    let s__to__sexp_with_layout (s: string) : Sexp_with_layout.t =
      let lexbuf = Lexing.from_string s in
      match Sexp_with_layout.(Parser.sexp Lexer.main lexbuf) with  
        | Comment _ -> raise No_Data
        | Sexp t -> t;;



  end

end

Error:

File "grs/grs.ml", line 18, characters 44-45:
18 |         | Atom (sloc, s, _) -> My_Atom sloc s
                                                 ^
Error: Syntax error: 'end' expected
File "grs/grs.ml", line 6, characters 19-25:
6 |   module My_Sexp = struct
                       ^^^^^^
  This 'struct' might be unmatched

This was bothering me last night; I figured a good night’s sleep would make the error obvious. Did not work, I’m still confused. XY problem: I’m removing useless fields from SexpLib.Sexp_with_layout to a format easier to work with.

Also, I have 2 structs, 0 begins, and 2 ends. I don’t understand what is mismatched.

My_Atom and My_List are not functions, they are constructors that take tuples (not curried arguments).

1 Like

I think this is the 2nd time this issue tripped me up. Thanks!