caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Leo White <leo@lpw25.net>
To: caml-list@inria.fr
Subject: Re: [Caml-list] exception Foo = Bar.Baz
Date: Tue, 26 Jul 2016 05:36:37 -0400	[thread overview]
Message-ID: <1469525797.2529112.676963937.25E14FD6@webmail.messagingengine.com> (raw)
In-Reply-To: <CAPFanBGdwrcDOasV5y5fJEqE1jdxAeze2=NkkToZxpuow9C-2w@mail.gmail.com>

> I think it would be nice for users that only read .mli files to know
> equalities between exceptions, for example if they want to reason on
> exhaustiveness of exception handling clauses with respect to a given
> (informal) exception specification.

I think this is more difficult than it appears. If you track equations
on exceptions then you need to make those equations behave properly with
respect to the various module operations. For example, you would need:

  module M : sig exception E end = ...

  module N = M

to end up with N having (a subtype of):

  sig exception E = M.E end

This gets tricky when you have applicative functors. For OCaml's other
equations (i.e. types, modules, module types) the following code:

  module F (X : S) : sig type t end = ...

  module M : S = ...

  module N = F(M)

gives N the type:

  module N : sig type t = F(M).t end

So you would expect the same to happen with exceptions:

  module F (X : S) : sig exception E end = ...

  module M : S = ...

  module N : sig exception E = F(M).E = F(M)

Unfortunately exception declarations are generative, so this equation is
"unsound". So either exception equations would need to be handled
completely differently from the other equations, or exception
definitions would need to be banned from applicative functors.

This is quite a lot of effort to go to for maintaining information that
is not providing any direct guarantees about program behavior. It is
also not particularly clear to me how materially different it is from
ordinary values: it would be nice to expose when they were aliases in
their types sometimes, but it does not really seem worth the cost.

Regards,

Leo

  reply	other threads:[~2016-07-26  9:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-25 14:34 Matej Kosik
2016-07-25 20:02 ` Alain Frisch
2016-07-25 20:05   ` Gabriel Scherer
2016-07-26  9:36     ` Leo White [this message]
2016-07-26 12:37       ` Gabriel Scherer
2016-07-26 16:27         ` Alain Frisch
2016-07-26 16:32           ` Gabriel Scherer
2016-07-27  8:07             ` Alain Frisch
2016-07-27  8:27               ` Gabriel Scherer
2016-07-27  8:38                 ` Alain Frisch
2016-07-27  8:19           ` Leo White
2016-07-26  9:02   ` Matej Kosik
2016-07-26 12:13     ` Gerd Stolpmann

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=1469525797.2529112.676963937.25E14FD6@webmail.messagingengine.com \
    --to=leo@lpw25.net \
    --cc=caml-list@inria.fr \
    /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).