From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA24193; Mon, 5 Mar 2001 22:27:11 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA23235 for ; Mon, 5 Mar 2001 22:27:11 +0100 (MET) Received: from mail.mimuw.edu.pl (pm12.warszawa.cvx.ppp.tpnet.pl [213.76.108.12]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f25LR4902516 for ; Mon, 5 Mar 2001 22:27:09 +0100 (MET) Received: (from news@localhost) by mail.mimuw.edu.pl (PLD/8.9.3) id WAA24457 for caml-list@inria.fr; Mon, 5 Mar 2001 22:24:07 +0100 X-Authentication-Warning: qrnik.zagroda: news set sender to qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk) using -f From: qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk) Subject: Re: [Caml-list] dynamically loading C functions Date: 5 Mar 2001 21:24:04 GMT Organization: Klub Nieszkodliwych =?iso-8859-2?Q?Manjak=F3w?= Message-ID: References: <4.3.2.7.2.20010304235205.00dea6a0@shell16.ba.best.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 8bit X-Trace: qrnik.zagroda 983827444 24455 192.168.0.1 (5 Mar 2001 21:24:04 GMT) X-Complaints-To: news@qrnik.zagroda NNTP-Posting-Date: 5 Mar 2001 21:24:04 GMT User-Agent: slrn/0.9.6.3 (Linux) To: caml-list@inria.fr Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Mon, 05 Mar 2001 12:28:26 -0800, Chris Hecker pisze: > - I can tell people to "cast" the 'a return type, so you'd do this: > > let f = (get_function "TheFunction: float -> float -> int" : float -> float -> int) > > but, this requires the error prone double-specification of the type, You can provide combinators to build the type information: val int_t : int t val float_t : float t val (@->) : 'a t -> 'b t -> ('a -> 'b) t (* Begins with @ so it's right-associative :-) *) val get_function : string -> 'a t -> 'a let f = get_function "TheFunction" (float_t @-> float_t @-> int_t) (I just imagined the idea in Haskell and translated implicit Haskell's type classes into explicit OCaml's dictionary passing.) -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTĘPCZA QRCZAK ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr