Loading ...
Sorry, an error occurred while loading the content.

13860Re: "ocaml_beginners"::[] How to hide a parametrized type ?

Expand Messages
  • Sébastien Dailly
    Mar 3, 2013
    • 0 Attachment
      Le 03/03/2013 14:14, Lukasz Stafiniak a écrit :
      > This is not possible since you define "G1" as no-argument variant in SIG
      > which you don't want. But it is possible to have private variant types,
      > where the programmer can see what the variants (and their arguments) are
      > but cannot build them.
      > http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual021.html#toc76

      Thanks for pointing private type; this is not exactly what I need, however I could get what I want with an abstract type :

      module type SIG =
      sig
      type t
      type g1
      type group =
      | G1 of g1
      end

      module Impl:SIG =
      struct
      type t
      type g1 = int
      type group =
      | G1 of g1
      end

      but I'm not complety satisfated : this means that I have a given signature, I can't implement it by adding some type without changing the type itself, and this add unecessary type, just for syntaxic sugar… I'll keep it for now…
    • Show all 3 messages in this topic