Update examples
This commit is contained in:
15
testsuite/eval/eval_fn1/Main.hs
Normal file
15
testsuite/eval/eval_fn1/Main.hs
Normal file
@ -0,0 +1,15 @@
|
||||
{-# OPTIONS -fglasgow-exts #-}
|
||||
--
|
||||
-- polymorphic eval!
|
||||
--
|
||||
|
||||
module Main where
|
||||
|
||||
import Poly
|
||||
import System.Eval.Haskell
|
||||
|
||||
main = do m_f <- eval "Fn (\\x y -> x == y)" ["Poly"]
|
||||
when (isJust m_f) $ do
|
||||
let (Fn f) = fromJust m_f
|
||||
putStrLn $ show (f True True)
|
||||
putStrLn $ show (f 1 2)
|
2
testsuite/eval/eval_fn1/Makefile
Normal file
2
testsuite/eval/eval_fn1/Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
TOP=../../..
|
||||
include ../../eval.mk
|
16
testsuite/eval/eval_fn1/Poly.hs
Normal file
16
testsuite/eval/eval_fn1/Poly.hs
Normal file
@ -0,0 +1,16 @@
|
||||
{-# OPTIONS -cpp -fglasgow-exts #-}
|
||||
module Poly where
|
||||
|
||||
import AltData.Typeable
|
||||
|
||||
data Fn = Fn {fn :: forall t. Eq t => t -> t -> Bool}
|
||||
|
||||
--
|
||||
-- ignore type inside the Fn... is this correct?
|
||||
--
|
||||
instance Typeable Fn where
|
||||
#if __GLASGOW_HASKELL__ >= 603
|
||||
typeOf _ = mkTyConApp (mkTyCon "Poly.Fn") []
|
||||
#else
|
||||
typeOf _ = mkAppTy (mkTyCon "Poly.Fn") []
|
||||
#endif
|
2
testsuite/eval/eval_fn1/expected
Normal file
2
testsuite/eval/eval_fn1/expected
Normal file
@ -0,0 +1,2 @@
|
||||
True
|
||||
False
|
Reference in New Issue
Block a user