caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk)
To: caml-list@inria.fr
Subject: Re: [Caml-list] dynamically loading C functions
Date: 5 Mar 2001 21:24:04 GMT	[thread overview]
Message-ID: <slrn9a80vk.nqi.qrczak@qrnik.zagroda> (raw)
In-Reply-To: <4.3.2.7.2.20010304235205.00dea6a0@shell16.ba.best.com>

Mon, 05 Mar 2001 12:28:26 -0800, Chris Hecker <checker@d6.com> 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


  reply	other threads:[~2001-03-05 21:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-05 20:28 Chris Hecker
2001-03-05 21:24 ` Marcin 'Qrczak' Kowalczyk [this message]
2001-03-06  0:10   ` Chris Hecker
2001-03-06  0:55     ` Chris Hecker
2001-03-06 16:48       ` Marcin 'Qrczak' Kowalczyk
2001-03-06 18:02         ` Chris Hecker
2001-03-08  8:22           ` Fabrice Le Fessant
2001-03-08  9:34             ` Chris Hecker
2001-03-09 10:54               ` Fabrice Le Fessant

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=slrn9a80vk.nqi.qrczak@qrnik.zagroda \
    --to=qrczak@knm.org.pl \
    --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).