Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はOCamlが初めてです。1 つの関数でのみ使用される型を定義したいと考えています。その機能の外で利用できるようにしたくありません。その関数内で定義できますか? または、同じことを達成する他の方法はありますか?
OCaml の最新バージョンを使用している場合は、ローカル モジュールを使用できます。
let f x = let module Local = struct type t = A | B end in ...
ただし、タイプを最上位で定義し、 から除外する方がより自然な場合が.mliあります。これにより、ファイル内の他のコードからは見えますが、グローバルには隠されます。
.mli