caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Erkki Seppala <flux@modeemi.cs.tut.fi>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Recursive fixed polymorphic variants
Date: Tue, 28 May 2013 09:36:55 +0300	[thread overview]
Message-ID: <m49txlnpq48.fsf@coffee.modeemi.fi> (raw)
In-Reply-To: <51A38A23.9000402@gmail.com> (Jacques-Pascal Deplaix's message of "Mon, 27 May 2013 18:30:27 +0200")

Hello,

Jacques-Pascal Deplaix <jp.deplaix@gmail.com> writes:

> let rec f = function `B x -> f x | `A -> ();;

The problem is that 'f' has two final types in the same scope - or
that's the best way I can describe it, someone can maybe chime in
:). One way to solve it for this instance would be:

let rec f = function `B x -> g x | `A -> ()
and g = function `B x -> f x | `A -> ();;

# f (M.b (M.a ()))
- : unit = ()

This gives f (and g) the inferred type ([< `A | `B of [< `A | `B of 'a
] ] as 'a) -> unit.

I was under the impression I should be able to describe using the type
variable syntax in function type, but I was unable to.

-- 
  _____________________________________________________________________
     / __// /__ ____  __               http://www.modeemi.fi/~flux/\   \
    / /_ / // // /\ \/ /                                            \  /
   /_/  /_/ \___/ /_/\_\@modeemi.fi                                  \/

  reply	other threads:[~2013-05-28  6:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-27 16:30 Jacques-Pascal Deplaix
2013-05-28  6:36 ` Erkki Seppala [this message]
2013-05-28  8:20   ` Leo White
2013-05-28  8:13 ` Leo White
2013-05-28 21:01   ` Jacques-Pascal Deplaix

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=m49txlnpq48.fsf@coffee.modeemi.fi \
    --to=flux@modeemi.cs.tut.fi \
    --cc=caml-list@yquem.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).