caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Segfault with open GADTs
Date: Tue, 18 Oct 2016 16:21:02 +0200	[thread overview]
Message-ID: <20161018142102.GA21704@frosties> (raw)
In-Reply-To: <ea2ae4ee-d242-0235-cce5-d90b7a59295b@digirati.com.br>

On Tue, Oct 18, 2016 at 11:52:40AM -0200, Andre Nathan wrote:
> On 10/18/2016 11:10 AM, Pierrick Couderc wrote:
> > Hi,
> > 
> > It is supposed to work, but it seems thepattern-matching compiler does
> > not detect that M0.to_string is non exhaustive, thus it does not add a
> > Match_Failure in case the variant is unknown. With extensible variants,
> > a pattern matching is only exhaustive if you provide a wildcard or a
> > variable for variants added afterwards. 
> 
> 
> Indeed, if I add a catch-all branch in M0.to_string then the code in
> that branch is run, with no segfault.
> 
> But I guess my original idea of extending the type doesn't really work
> as I hoped, since with nested expressions like that, I'd need to find a
> way for M0.to_string to call back M1.to_string when a `T` is found.
> 
> Back to the drawing board...
> 
> Thanks,
> Andre

You can pass along the outermost to_string to all to_string
functions so they can restart from the outside when they recurse.

MfG
	Goswin

  reply	other threads:[~2016-10-18 14:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-18 12:47 Andre Nathan
2016-10-18 13:10 ` Pierrick Couderc
2016-10-18 13:52   ` Andre Nathan
2016-10-18 14:21     ` Goswin von Brederlow [this message]
2016-10-18 14:50       ` Andre Nathan
2016-10-18 13:16 ` Jeremy Yallop

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=20161018142102.GA21704@frosties \
    --to=goswin-v-b@web.de \
    --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).