caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Olivier Andrieu <andrieu@ijm.jussieu.fr>
To: alex@barettadeit.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] generic functions
Date: Mon, 10 Jan 2005 11:47:16 +0100 (CET)	[thread overview]
Message-ID: <20050110.114716.71093554.andrieu@ijm.jussieu.fr> (raw)
In-Reply-To: <41E25116.1010805@barettadeit.com>

 Alex Baretta [Mon, 10 Jan 2005]:
 > type poly_int = [ `Int of int ]
 > type poly_float = [ `Float of float ]
 > 
 > let foo_int foo = function
 >    | `Int x -> `Int(x * x)
 >    | other -> foo other
 > 
 > let foo_float foo = function 
 >    | `Float x -> `Float(x *. x) 
 >    | other -> foo other
 > 
 > let rec foo x = match x with
 >    | #poly_int -> foo_int foo x
 >    | #poly_float -> foo_float foo x

Hum, I would have written this in that way :
,----
| let foo_int   (`Int x)   = `Int   (x * x)
| let foo_float (`Float x) = `Float (x *. x)
| 
| let foo = function
|   | #poly_int   as x -> foo_int x
|   | #poly_float as x -> foo_float x
`----

What's the use for the `other -> foo other' clauses ?

-- 
   Olivier


  reply	other threads:[~2005-01-10 10:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-09 13:19 wiedergaenger
2005-01-09 14:56 ` [Caml-list] " Richard Jones
2005-01-09 15:48 ` Brian Hurt
2005-01-09 17:17   ` David McClain
2005-01-09 18:09     ` brogoff
2005-01-09 18:45   ` padiolea
2005-01-10  0:23   ` skaller
2005-01-11 12:14     ` Daniel Yokomizo
2005-01-10  9:55   ` [Caml-list] " Alex Baretta
2005-01-10 10:47     ` Olivier Andrieu [this message]
2005-01-10 12:16       ` Alex Baretta
2005-01-12 23:49     ` Aleksey Nogin

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=20050110.114716.71093554.andrieu@ijm.jussieu.fr \
    --to=andrieu@ijm.jussieu.fr \
    --cc=alex@barettadeit.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;
as well as URLs for NNTP newsgroup(s).