caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Bruno De Fraine <Bruno.De.Fraine@vub.ac.be>
To: ocaml ml <caml-list@inria.fr>
Subject: Re: RE : [Caml-list] empty type
Date: Tue, 20 Feb 2007 10:05:05 +0100	[thread overview]
Message-ID: <0FFA89B7-7D72-4E67-988F-052D855CD224@vub.ac.be> (raw)
In-Reply-To: <45D9CA6E.8020008@fmf.uni-lj.si>

On 19 Feb 2007, at 17:03, Andrej Bauer wrote:

> Mathias Kende wrote:
>> It's not a type, but just a valid name for a constructor that can be
>> redefined if necessary (although one surely does not want to do so).
>
> Way cool:
>
> # type t = () of int * int ;;
> type t = () of int * int
> # () (3, 4) ;;
> - : t = () (3, 4)

If you redefine :: you get an infix constructor:

# type expr = Num of int | :: of expr * expr ;;
type expr = Num of int | :: of expr * expr
# Num 1 :: Num 2 :: Num 3 ;;
- : expr = :: (Num 1, :: (Num 2, Num 3))
# :: (Num 2, Num 3) ;;
Syntax error
# let a :: b = Num 1 :: Num 2 :: Num 3 ;;
Warning P: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
Num _
val a : expr = Num 1
val b : expr = :: (Num 2, Num 3)

Bruno

-- 
Bruno De Fraine
Vrije Universiteit Brussel
Faculty of Applied Sciences, INFO - SSEL
Room 4K208, Pleinlaan 2, B-1050 Brussels
tel: +32 (0)2 629 29 75
fax: +32 (0)2 629 28 70
e-mail: Bruno.De.Fraine@vub.ac.be



  parent reply	other threads:[~2007-02-20  9:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-19 13:47 Fernando Alegre
2007-02-19 14:14 ` [Caml-list] " skaller
2007-02-19 14:23   ` RE : " Mathias Kende
2007-02-19 16:03     ` Andrej Bauer
2007-02-19 20:51       ` Fernando Alegre
2007-02-20  9:05       ` Bruno De Fraine [this message]
2007-02-19 22:36 ` Richard Jones

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=0FFA89B7-7D72-4E67-988F-052D855CD224@vub.ac.be \
    --to=bruno.de.fraine@vub.ac.be \
    --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).