caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Steven Murdoch <steven@murdomedia.net>
To: caml-list@inria.fr
Subject: [Caml-list] Haskell features in O'Caml
Date: Sat, 22 Sep 2001 12:46:02 +0100	[thread overview]
Message-ID: <4.3.2.7.2.20010922124022.026dbba0@pop.ntlworld.com> (raw)

I've been using Haskell a little for the past year or so and I like
quite a few of it's features, more recently I thought I'd look into
O'Caml and I've been impressed by it's speed and versatility but I was
wondering if it had some features found in Haskell.

The main one I would like is the type assertion facility of Haskell.
For example, one might write:
mul :: Int -> Int -> Int
mul a b = a * b
The Haskell compiler will deduce the type of mul from the second line
in a similar way to O'Caml and if it does not match the first line an
error is raised.

I find that this catches a lot of my mistakes and it would be great if
O'Caml has a similar way to check whether the implied type of a
function matches (or is a subtype of) an explicit definition.

Another feature I would like is whether it is possible to define
custom operators that can be put between it's operands rather than in
front of them. For example if max gives the maximum of two arguments
it can be applied normally, i.e. "max 2 3" will return 3, but "2
`max` 3" will also return 3.
Also if a function is named using operator symbols it can be used as
an operator, e.g if &&& is defined as:
(&&&) :: Int -> Int -> Int
x &&& y = max x y
then "2 &&& 3" will return 3
This can lead to some very easy to read programs so I would like to
know if either or both of these ways of defining operators has a
equivalent in O'Caml.

Thanks in advance,
Steven Murdoch.


--
email: steven@murdomedia.net
web: http://www.murdomedia.net/
PGP/GnuPG keys: http://www.murdomedia.net/keys.html

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


             reply	other threads:[~2001-09-22 11:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-22 11:46 Steven Murdoch [this message]
2001-09-22 14:56 Arturo Borquez
2001-09-23 16:08 ` Florian Hars
2001-09-23 16:21 ` Mattias Waldau
2001-09-23 17:50   ` Dave Mason
2001-09-24 11:14     ` Sven
2001-09-24 15:29       ` Brian Rogoff
2001-09-23 23:25 Arturo Borquez
2001-09-24 16:26 Christian.Schaller
2001-09-24 19:53 ` Remi VANICAT
2001-09-24 22:51 Christian.Schaller
2001-09-25  9:15 ` Remi VANICAT

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=4.3.2.7.2.20010922124022.026dbba0@pop.ntlworld.com \
    --to=steven@murdomedia.net \
    --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).