From: Goswin von Brederlow <goswin-v-b@web.de>
To: Dan Bensen <danbensen@att.net>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] extending user-defined polymorphic variant types
Date: Mon, 07 May 2012 18:47:42 +0200 [thread overview]
Message-ID: <877gwokkep.fsf@frosties.localnet> (raw)
In-Reply-To: <1336383633.2612.YahooMailRC@web180006.mail.gq1.yahoo.com> (Dan Bensen's message of "Mon, 7 May 2012 02:40:33 -0700 (PDT)")
Dan Bensen <danbensen@att.net> writes:
> I'm trying to write a functor that extends a user-supplied polymorphic
> variant type (PVT). How do you declare the user's type in the signature
> for the argument to the functor without locking in the individual variant
> definitions?
> The code below (in revised syntax) generates an error message that says
> the type isn't a PVT.
>
> code:
>
>> module type Reader = sig type ast; end;
>>
>> module Make (Read: Reader) = struct
>> type ast = [= Read.ast | `Lid of string];
>> end;
>
> message:
>
>> Error: The type Read.ast is not a polymorphic variant type
>
> How do you make ast a PVT while allowing the user to
> specify the variants?
Even if that did work how usefull would that be? You couldn't write
let foo = function
| `Lid s -> ()
| x -> Read.foo x
unless Read.foo allows [> Read.ast]. In which case you don't need a
functor but can just implement foo straight up.
What is your use case? What do you want to do?
MfG
Goswin
next prev parent reply other threads:[~2012-05-07 16:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-07 9:40 Dan Bensen
2012-05-07 11:37 ` Philippe Veber
2012-05-07 16:47 ` Goswin von Brederlow [this message]
2012-05-07 18:55 ` Dan Bensen
2012-05-07 20:17 ` Dan Bensen
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=877gwokkep.fsf@frosties.localnet \
--to=goswin-v-b@web.de \
--cc=caml-list@inria.fr \
--cc=danbensen@att.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).