git @ Cat's Eye Technologies Pail / b3c21eb
Test with both ghc and Hugs. Cat's Eye Technologies 8 years ago
4 changed file(s) with 41 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
0 module Main where
1
2 import System.Environment
3 import Pail
4
5 main = do
6 [fileName] <- getArgs
7 c <- readFile fileName
8 putStrLn $ runPail c
224224 Outer Reduction
225225 ---------------
226226
227 An evaluation of some expression x o-reduces to the i-reduction of its
228 contents.
227 An evaluation of an expression o-reduces to the i-reduction of its contents.
229228
230229 > oReduce env (Eval x) = iReduce env x
231230
267266 things will get even worse), we use the terminology that a function
268267 "returns" a value here, rather than "reducing" or "evaluating" to one.
269268
270 Applying `fst` to a pair (resp. `snd`) returns the o-reduction of the
269 Applying `fst` (resp. `snd`) to a pair returns the o-reduction of the
271270 first (resp. second) element of that pair.
272271
273272 > pFst env (Pair a _) = oReduce env a
315314 above defined functions with a symbol.
316315
317316 > stdEnv :: Env
318 > stdEnv = Map.fromList (map (\(name, fun) -> (name, (Fn name fun)))
317 > stdEnv = Map.fromList $ map (\(name, fun) -> (name, (Fn name fun)))
319318 > [
320319 > ("fst", pFst),
321320 > ("snd", pSnd),
323322 > ("type-of", pTypeOf),
324323 > ("uneval", pUnEval),
325324 > ("let", pLet)
326 > ])
325 > ]
327326
328327
329328 Top-Level Driver
00 #!/bin/sh
1 cd src && falderal test ../tests/Pail.markdown
1
2 if [ x`which ghc` = x -a x`which runhugs` = x ]; then
3 echo "Neither ghc nor runhugs found on search path"
4 exit 1
5 fi
6
7 touch fixture.markdown
8
9 if [ ! x`which ghc` = x ]; then
10 cat >>fixture.markdown <<EOF
11 -> Functionality "Evaluate Pail Expression" is implemented by
12 -> shell command
13 -> "ghc -e "do c <- readFile \"%(test-file)\"; putStrLn $ Pail.runPail c" src/Pail.lhs"
14
15 EOF
16 fi
17
18 if [ ! x`which runhugs` = x ]; then
19 cat >>fixture.markdown <<EOF
20 -> Functionality "Evaluate Pail Expression" is implemented by
21 -> shell command
22 -> "runhugs src/Main.hs %(test-body-file)"
23
24 EOF
25 fi
26
27 falderal fixture.markdown tests/Pail.markdown
28 rm -f fixture.markdown
88 ----------
99
1010 -> Tests for functionality "Evaluate Pail Expression"
11
12 -> Functionality "Evaluate Pail Expression" is implemented by
13 -> shell command
14 -> "ghc -e "do c <- readFile \"%(test-file)\"; putStrLn $ Pail.runPail c" Pail.lhs"
1511
1612 A symbol reduces to that symbol.
1713