[Haskell-cafe] embedding Haskell: problematic polymorphism

Claude Heiland-Allen claudiusmaximus at goto10.org
Wed Jul 11 13:45:40 EDT 2007

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.

Thanks for any insights,


[0] http://puredata.info

[1] Data.Dynamic> (fromDynamic (toDyn (3.5::Double)))::(Typeable a => 
Maybe a)

     Ambiguous type variable `a' in the constraint:
       `Typeable a'
         arising from instantiating a type signature at <interactive>:1:0-59
     Probable fix: add a type signature that fixes these type variable(s)


More information about the Haskell-Cafe mailing list