[Haskell-cafe] embedding Haskell: problematic polymorphism

Stefan O'Rear stefanor at cox.net
Wed Jul 11 15:00:24 EDT 2007


On Wed, Jul 11, 2007 at 05:45:40PM +0000, Claude Heiland-Allen wrote:
> Hi people,
>
> I'm embedding Haskell into a C program with a "stateful objects with 
> message passing" paradigm [0].  I want to make "boxes" with useful 
> functions, then connect them together within the C program.  I know how to 
> build a working version using Data.Dynamic, but that loses polymorphism 
> [1].
>
> Say I have 3 boxes:
>
> Box 1:  [1,2,5,3]        :: [Float]
> Box 2:  reverse          :: [a] -> [a]
> Box 3:  putStrLn . show  :: (Show b) => b -> IO ()
>
> I wonder, is it possible to create these boxes separately at runtime (each 
> box being compiled/loaded separately with hsplugins), then connect them 
> together like {Box 1}=>{Box 2}=>{Box 3} (with a wrapping layer doing 
> appropriate type checking/error reporting), or does the whole thing need to 
> be compiled statically to generate specialized variants of the polymorphic 
> functions?  As hinted in #haskell :
>
> <quicksilver> ClaudiusMaximus: I don't think anything will allow you to 
> pass around polymorphic values. They're an illusion of the type-checker, in 
> a sense.

There is nothing intrinsically impossible with a Data.Dynamic like
interface for polytypic values.  Good luck writing toDyn and fromDyn
without compiler support, however.

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070711/fff34f00/attachment.bin


More information about the Haskell-Cafe mailing list