41 lines
1.2 KiB
Haskell
Raw Normal View History

2005-04-24 08:51:33 +00:00
{-# OPTIONS -cpp #-}
--
-- Should evaluate to '3', unless something goes wrong.
--
-- Not so bad to use AltData, as it is already derived for all the basic
-- types. Then, just replace deriving Typeable, with hand-derived
-- instance of Typeable (see hs-plugins/examples/eval/eval_fn1/Poly.hs
--
--
#include "../../../config.h"
import System.Eval
2005-04-24 08:51:33 +00:00
import AltData.Dynamic
pkgconf = TOP ++ "/plugins.conf.inplace"
main = do
a <- return $ toDyn (3::Integer)
2005-04-24 08:51:33 +00:00
-- so, we try to compile a function that takes a dyn.
-- looks like with GHC 6.4, we need to make sure the package.confs work:
m_b <- unsafeEval_ "\\dyn -> fromDyn dyn (7 :: Integer)"
["AltData.Dynamic"]
2005-04-24 08:51:33 +00:00
[ "-package-conf "++pkgconf , "-package altdata" ]
[ pkgconf ]
[]
case m_b of
Left s -> mapM_ putStrLn s
Right b -> putStrLn $ show (b a :: Integer) -- now apply it
2005-04-24 08:51:33 +00:00
{-
-- should work, but doesn't. type check fails
-- (due to static vs dynamic typing issue)
m_b <- unsafeEval_ "\\dyn -> fromMaybe (7 :: Int) (fromDynamic dyn)"
["Data.Dynamic","Data.Maybe"] [] []
-}