caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Memoize GADT
@ 2013-02-06  8:19 Christophe Papazian
  2013-02-06  9:50 ` Alain Frisch
  2013-02-06  9:55 ` Gabriel Scherer
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe Papazian @ 2013-02-06  8:19 UTC (permalink / raw)
  To: Caml List

Hi,

this must be a very basic question for some of you, sorry for the inconvenience :

When I have function "f" of type (a -> b), I can easily add a layer to that function to memoize the result by using a (a,b) Hashtbl.t to store the results of the expensive to compute "f".

let mf = let e = Hashtbl.create 0 in ( fun x -> try Hashtbl.find e x with Not_found -> let res = f x in Hashtbl.add e x res; res )

But now, I have a function "g" 
	let g (type a) : a gadt -> a = ....

And If I apply the same method, type a becomes weak (_'a).

Is there something simple to memoize that function as easy as the previous example and keep its polymorphism ? I think not, but I hope to be wrong.

Thanks

	Christophe


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-02-06  9:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-06  8:19 [Caml-list] Memoize GADT Christophe Papazian
2013-02-06  9:50 ` Alain Frisch
2013-02-06  9:55 ` Gabriel Scherer

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