From: "Markus Mottl" <markus.mottl@gmail.com>
To: ocaml <caml-list@inria.fr>
Subject: Problem specializing types in signatures
Date: Fri, 16 May 2008 14:26:12 -0400 [thread overview]
Message-ID: <f8560b80805161126w743b22f1t904f0c6103d2b865@mail.gmail.com> (raw)
Hi,
I have just recently run into a slightly annoying problem specializing
types in signatures, e.g.:
module type A = sig type t end
module type B = sig include A with type t = X end
The above will lead to a syntax error, because sum types, as well as
record types, cannot be used in the definition of t in the "with t =
..." part. But there does not seem to be an obvious reason why this
shouldn't be allowed, because one can always just manually replace
"include A" with "A" and add the corresponding right hand side of the
type.
We cannot specify that e.g. a function returns a record by just
placing the type definition of the record in the signature of the
function. We first have to bind the record definition to a type name,
otherwise type errors would be much harder to understand. But this is
not the case here: we already have a type name to refer to, namely "t"
so this explanation for this behavior doesn't seem to apply.
Shouldn't it be possible to relax the language rules here to allow
direct definitions of types? Or am I missing potential pitfalls here?
Btw., a clumsy workaround requiring the introduction of a dummy type
is the following:
module type B = sig
type x = X
include A with type t = x
end
Regards,
Markus
P.S.: A commentator on one of our blog articles also ran into a
similar issue: http://ocaml.janestcapital.com/?q=node/26
--
Markus Mottl http://www.ocaml.info markus.mottl@gmail.com
reply other threads:[~2008-05-16 18:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=f8560b80805161126w743b22f1t904f0c6103d2b865@mail.gmail.com \
--to=markus.mottl@gmail.com \
--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