caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: Marek Kubica <marek@xivilization.net>
Cc: OCaML List Mailing <caml-list@inria.fr>
Subject: Re: [Caml-list] [ANN] slacko-0.9.0
Date: Sun, 5 Oct 2014 11:23:09 +0900	[thread overview]
Message-ID: <AF3ED575-1605-48E0-9296-9F9CF0C05729@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <20141005004338.6af9622f@xivilization.net>

On 2014/10/05 07:43, Marek Kubica wrote:
> 
> Hello Gabriel,
> 
> On Sat, 4 Oct 2014 17:23:02 +0200
> Gabriel Scherer <gabriel.scherer@gmail.com> wrote:
> 
>> `kick` now returns a [> error_cant_kick | `Success of 'a ], while
>> `invite` returns [> error_cant_invite | `Success of 'a ].
> 
> Thank you for this idea, I was actually looking for a way to define
> subsets of polymorphic variants, I didn't know that I can just put them
> into other types and was unaware of the # syntax. Now my functions
> return just the possible error variants, not all of them anymore.
> 
> I've reworked the code to get rid of the huge apierror type (which I
> suppose I can throw away completely, since a user of the API will never
> need it anyway), but it lead to quite huge blow-up of signatures:
> 
> <https://github.com/Leonidas-from-XIV/slacko/blob/37c3626bb9574bc99325267fb4c9f9c3c4f4730c/src/slacko.mli>
> 
> I am going to simplify these subsets a bit (since e.g. all history
> methods use the same polymorphic variants and some possible error types
> imply other error types) but it kinda looks very verbose now - any hints
> on what can be done?

I don’t think it’s particularly verbose.
You have documented all the possible errors for each function, which is
valuable information, and it would take the same space (or more) if you
were to write this in comments.
If you think this is hard to read, you can try some factorization, but I’m not
sure it would help. Also, from a stylistic point of view I would write variant
definitions on a single line, since there are never more than 3 cases.

This said, there is always a tension between safety an complexity.
If in practice static checking of possible errors doesn’t matter that much,
it would be easier to write this code using normal variants.

Jacques Garrigue

      reply	other threads:[~2014-10-05  2:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-04 13:05 Marek Kubica
2014-10-04 13:36 ` Malcolm Matalka
2014-10-04 14:54   ` Marek Kubica
2014-10-04 15:23     ` Gabriel Scherer
2014-10-04 22:43       ` Marek Kubica
2014-10-05  2:23         ` Jacques Garrigue [this message]

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=AF3ED575-1605-48E0-9296-9F9CF0C05729@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=marek@xivilization.net \
    /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;
as well as URLs for NNTP newsgroup(s).