Mon, 31 Jul 2000 11:58:19 +0200, Sven-Bodo Scholz <[EMAIL PROTECTED]> pisze:
> f:: Num a => a -> a
>
> Is there any way to export "all potential versions of f" ????
No. It would be hard even to define what it could mean.
> Or do I have to export each version separately, e.g.:
>
> foreign export ccall "fInt" f :: Int -> Int
> foreign export ccall "fFloat" f :: Float -> Float
Yes. Or wrap the function in an appropriate polymorphic interface
that uses concrete types on the C side, probably using StablePtr.
Depending on what exactly you want to archieve (how to use these
functions in C), various methods may be appropriate.
> The next step would be to ask how to export polymorphism such as
>
> id:: a -> a
>
> Is there a convenient way for exporting these functions??
How would you use such function in C? C does not support polymorphism
directly.
StablePtr provide a way to wrap a Haskell value in an abstract C
value that can be later passed back to Haskell and dereferenced.
foreign export dynamic allows wrapping a Haskell function in a C
function pointer. Although the interface of such function must use
only types available from C, it's a closure, so theoretically can be
used for things involving arbitrary types.
--
__("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
\__/ GCS/M d- s+:-- a23 C+++$ UL++>++++$ P+++ L++>++++$ E-
^^ W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK 5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-