caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "François-Xavier HOUARD" <IdeFX@Iname.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] troubles with polymorphic variant in class
Date: Mon, 14 Jun 2004 11:29:01 +0200	[thread overview]
Message-ID: <1087205340.8886.4.camel@Bess> (raw)
In-Reply-To: <1087149590.16811.1342.camel@pelican.wigram>

Le dim 13/06/2004 à 19:59, skaller a écrit :

> (* fixpoint *)
> type widget = 'w widget' as 'w 
> 
> which effectively solves the type equation
> 'w = 'w widget (and names the result widget).
> Now define non-polymorphic classes:
> 
> class button = [widget] button'
> class window = [widget] window'
> 
> This is not so bad for a single parameter 'w.
> For multiple parameters the notation soon becomes
> too unwieldy to be practical. 

But the answer you gave me, which I find quite nice, don't allow my user
to add his own class....
I could do the stuff with a parametrized module (the parameter given by
the user would contain the variant used in the program... Including the
ones of my library!!), or, even uglier, use a close variant in my
module, which would be like:
[ Window of window | Frame of frame | User_variant of 'a ]

And 'a, the parameter of the module, given by the user, would also be a
variant...

module SillyModule =
struct
	type t = [ MyWindow of myWindow | MyText of myText ];;
end
;;
module myGui = Gui (SillyModule);;
let a = new Window;;
let x = new myText a;;
let l = a#get_child in
match l with
h::t -> (match h with 
	 	myGui.User_variant v ->
			( match v with
			    MyText t -> .......
			    | _ ->
			)
		| _ -> raise Not_found
	)
....


Who the hell would use this ??? 

So, if I can't find a better solution, i could still try to find a
sado-m(l)asochist mailing list, to find potential users !

;))


Let's be more serious. What you said is fine, but, please, tell me there
is an easier solution to make it work with user defined class...
Please....

Thanks for all

FX Houard, desperate to find an elegant and extensible solution to his
problem... And attracted by the dark-dynamic-typed side of coca-ml.

-------------------
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


  reply	other threads:[~2004-06-14  9:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-13 16:05 François-Xavier HOUARD
2004-06-13 17:59 ` skaller
2004-06-14  9:29   ` François-Xavier HOUARD [this message]
2004-06-14  9:48     ` Damien Doligez
2004-06-14 15:49     ` skaller
2004-06-14  9:37 ` Richard Jones
2004-06-14 14:48 ` nakata keiko

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=1087205340.8886.4.camel@Bess \
    --to=idefx@iname.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).