Redundancy in OCaml type declaration (ml/mli)

前端 未结 5 446
北海茫月
北海茫月 2020-12-25 10:41

I\'m trying to understand a specific thing about ocaml modules and their compilation:

am I forced to redeclare types already declared in a .mli inside t

5条回答
  •  清歌不尽
    2020-12-25 11:32

    Yes, you are forced to redeclare types. The only ways around it that I know of are

    • Don't use a .mli file; just expose everything with no interface. Terrible idea.

    • Use a literate-programming tool or other preprocessor to avoid duplicating the interface declarations in the One True Source. For large projects, we do this in my group.

    For small projects, we just duplicate type declarations. And grumble about it.

提交回复
热议问题