Import hs-plugins cvs
This commit is contained in:
42
examples/eval/eval3/Main.hs
Normal file
42
examples/eval/eval3/Main.hs
Normal file
@ -0,0 +1,42 @@
|
||||
{-# 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 Eval.Haskell
|
||||
import AltData.Dynamic
|
||||
|
||||
-- import Data.Dynamic
|
||||
|
||||
pkgconf = TOP ++ "/plugins.conf.inplace"
|
||||
|
||||
main = do
|
||||
a <- return $ toDyn (3::Int)
|
||||
|
||||
m_b <- unsafeEval_ "\\dyn -> fromMaybe (7 :: Int) (fromDyn dyn)"
|
||||
["AltData.Dynamic","Data.Maybe"] -- imports
|
||||
|
||||
[ "-package-conf "++pkgconf , "-package altdata" ]
|
||||
|
||||
[ pkgconf ]
|
||||
[]
|
||||
|
||||
|
||||
{-
|
||||
-- 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"] [] []
|
||||
-}
|
||||
|
||||
case m_b of
|
||||
Left s -> mapM_ putStrLn s
|
||||
Right b -> putStrLn $ show (b a :: Int)
|
2
examples/eval/eval3/Makefile
Normal file
2
examples/eval/eval3/Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
TOP=../../..
|
||||
include ../../eval.mk
|
1
examples/eval/eval3/expected
Normal file
1
examples/eval/eval3/expected
Normal file
@ -0,0 +1 @@
|
||||
3
|
Reference in New Issue
Block a user