From: skaller <skaller@users.sourceforge.net>
To: David Brown <caml-list@davidb.org>
Cc: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>,
n8gray@gmail.com, caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Single-case union types as strong typedefs
Date: 23 Oct 2004 15:00:02 +1000 [thread overview]
Message-ID: <1098507602.7584.163.camel@pelican.wigram> (raw)
In-Reply-To: <20041023033915.GA22739@old.davidb.org>
On Sat, 2004-10-23 at 13:39, David Brown wrote:
> On Sat, Oct 23, 2004 at 12:31:39PM +0900, Jacques Garrigue wrote:
>
> > The problem you describe only occurs when your single constructor has
> > only one argument.
> > Indeed, this would be nice to have the overhead compiled away.
> > I don't remember whether there was a concrete reason not to.
>
> Another reason is that is breaks compatibility with existing C bindings, or
> at least potentially does.
That problem would go away with the 'newtype' Jaques mentioned.
I'm curious about newtype, since it could do more,
and would have to I think, to be worthwhile ..
This:
newtype metres = float
meaning
type metres = Metres float
means you have to define all the operations on 'metres' all
over again:
let (++) (Metres x) (Metres y) = Metres (x .+ y)
I'd guess in Haskell newtype can benefit from typeclasses?
How about using functors in Ocaml somehow .. make 'metres' just
an abstract type via a functor Make.length representing the
typeclass of lengths?
Actually for quantities, you'd use some phantom types
so you could represent products of the dimensions,
such as square metres too .. so the simplistic
constructor representation isn't very good.
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2004-10-23 5:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-23 1:49 Nathaniel Gray
2004-10-23 3:31 ` Jacques Garrigue
2004-10-23 3:39 ` David Brown
2004-10-23 5:00 ` skaller [this message]
2004-10-23 21:49 ` Nathaniel Gray
2004-10-23 21:24 ` Nathaniel Gray
2004-10-23 21:33 ` Nathaniel Gray
2004-10-24 3:00 ` John Prevost
2004-10-24 5:18 ` skaller
2004-10-24 22:52 ` Nathaniel Gray
2004-10-25 13:21 ` Damien Doligez
2004-10-25 14:25 ` Jacques Carette
2004-10-26 14:07 ` Damien Doligez
2004-10-26 15:05 ` Jacques Carette
2004-10-26 17:34 ` skaller
2004-10-26 20:02 ` [Caml-list] Combined compilation and linking Jon Harrop
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=1098507602.7584.163.camel@pelican.wigram \
--to=skaller@users.sourceforge.net \
--cc=caml-list@davidb.org \
--cc=caml-list@inria.fr \
--cc=garrigue@kurims.kyoto-u.ac.jp \
--cc=n8gray@gmail.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