From: skaller <skaller@users.sourceforge.net>
To: Jon Harrop <jon@ffconsultancy.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] parameterized pattern
Date: Thu, 09 Nov 2006 19:51:20 +1100 [thread overview]
Message-ID: <1163062280.28049.110.camel@rosella.wigram> (raw)
In-Reply-To: <200611090519.45998.jon@ffconsultancy.com>
On Thu, 2006-11-09 at 05:19 +0000, Jon Harrop wrote:
> On Thursday 09 November 2006 01:45, brogoff wrote:
> > It's a pity, as I've often wished that OCaml supported the extensional
> > polymorphism that GCaml has, but I don't think that's going to happen.
> > It would probaby make more sense to create a separate language at this
> > point, since OCaml is complicated enough.
>
> I think F# provides some form of extensional polymorphism. I'm not convinced
> that it is a good idea yet...
Well FYI Felix has traditional (open) overloading, but since it
doesn't allow traditional C++ style dependent name lookup because
that would destroy parametricity of polymorphic functions,
something else was needed.
So it now has first order typeclasses to solve this problem.
[By first order I mean typeclass arguments can be types but
not type constructors, i.e. it only supports data polymorphism,
not functorial polymorphism/polyadic programming]
This allows you to write stuff like this:
typeclass Integer[t] {
virtual fun add: t * t -> t;
}
fun sum3[t where Integer[t]] (x:t,y:t,z:t)=> add(x,add(y,z));
print (sum3(1,2,3));
instance Integer[int] {
fun add: int * int -> int = "$1+$2"; // C code
}
open Integer[int];
print (add(add(1,2),3));
I'm not sure i really like typeclasses much, ML functors
seem more general, and the coupling is explicit.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
next prev parent reply other threads:[~2006-11-09 8:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-06 21:15 Serge Aleynikov
2006-11-06 23:58 ` [Caml-list] " Jon Harrop
2006-11-07 0:12 ` Serge Aleynikov
2006-11-06 23:59 ` Martin Jambon
2006-11-08 23:55 ` Lukasz Stafiniak
2006-11-09 1:45 ` brogoff
2006-11-09 5:19 ` Jon Harrop
2006-11-09 8:51 ` skaller [this message]
2006-11-09 16:22 ` brogoff
2006-11-09 17:55 ` skaller
2006-11-14 23:12 ` Don Syme
2006-11-15 1:00 ` brogoff
2006-11-15 1:36 ` Don Syme
2006-11-09 5:18 ` Jon Harrop
2006-11-09 16:42 ` micha
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=1163062280.28049.110.camel@rosella.wigram \
--to=skaller@users.sourceforge.net \
--cc=caml-list@yquem.inria.fr \
--cc=jon@ffconsultancy.com \
/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