39 lines
1.1 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
2005-09-03 04:45:14 +00:00
-- instance of Typeable (see hs-plugins/testsuite/eval/eval_fn1/Poly.hs
2005-04-24 08:51:33 +00:00
--
--
#include "../../../config.h"
import System.Eval
2007-01-29 03:18:27 +00:00
import Data.Dynamic
2005-04-24 08:51:33 +00:00
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)"
2007-01-29 03:18:27 +00:00
["Data.Dynamic"]
[ ]
[ ]
2005-04-24 08:51:33 +00:00
[]
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"] [] []
-}