From: "Frédéric Bour" <frederic.bour@lakaban.net>
To: Trevor Smith <trevorsummerssmith@gmail.com>
Cc: "Török Edwin" <edwin+ml-ocaml@etorok.net>, caml-list@inria.fr
Subject: Re: [Caml-list] Type Constraints and .mli
Date: Fri, 08 Aug 2014 08:20:32 +0001 [thread overview]
Message-ID: <1407485972.2631.1@mail.lakaban.net> (raw)
In-Reply-To: <CAG-KTt9wSje3EbR2Zzzo3CqB8Lfj4iNS1Ki91u0AEC9HZ6ZdBg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1324 bytes --]
Le jeu. 7 août 2014 à 23:06, Trevor Smith
<trevorsummerssmith@gmail.com> a écrit :
> Edwin,
>
> Thank you for your response.
>
> You are correct that the "val t" in my example should read "type t".
>
> My main goal is one of readability: I want to have large swathes of
> the codebase only use the immutable interface. A few, but very few,
> parts of the codebase will use the mutable interface. Ideally, I want
> the developer reading the .mli files to quickly and easily understand
> what interfaces do what. The standard way of adding the type
> constraints add a lot of syntax and make it (slightly) harder to
> read. My entire question is sort of a nitpick.
Hi, I am not sure I understood your problem but I'll try to provide
some info.
The standard way of adding "type constraints" is by just exposing the
equality between types in the interface. In your case:
character.mli:
type t = CharacterImpl.t
val create : string -> t
val name : t -> string
mCharacter.mli:
type t = CharacterImpl.t
val create : string -> t
val name : t -> string
val set_name : t -> string -> unit
Which is what express "CharacterSig with type t = CharacterImpl.t":
create a new signature by taking "CharacterSig" and replacing "type t"
by "type t = CharacterImpl.t".
[-- Attachment #2: Type: text/html, Size: 2636 bytes --]
next prev parent reply other threads:[~2014-08-08 8:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-06 12:14 Trevor Smith
2014-08-06 15:36 ` Török Edwin
2014-08-07 22:06 ` Trevor Smith
2014-08-08 8:19 ` Frédéric Bour [this message]
2014-08-06 22:06 ` Nick Lucaroni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1407485972.2631.1@mail.lakaban.net \
--to=frederic.bour@lakaban.net \
--cc=caml-list@inria.fr \
--cc=edwin+ml-ocaml@etorok.net \
--cc=trevorsummerssmith@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox