git @ Cat's Eye Technologies Pail / rel_1_0_2019_0326
Merge pull request #1 from catseye/develop-2019-1 Develop 2019-1 Chris Pressey authored 2 years ago GitHub committed 2 years ago
19 changed file(s) with 210 addition(s) and 41 deletion(s). Raw diff Collapse all Expand all
0 *.hi
1 *.o
2 *.jsmod
3 bin/*.exe
4 demo/pail.js
+0
-3
.hgtags less more
0 bd8de915db4a51871a48f294415c9e9aff87fe99 rel_1_0_2011_1214
1 e2a82befac8991d9b1e7718cb73f8726794f3852 rel_1_0_2014_0819
2 9a4f985dca5a33bcc9d6826f41b10de40e755ee6 rel_1_0_2016_0304
0 Copyright (c)2011-2016 Chris Pressey, Cat's Eye Technologies.
0 Copyright (c)2011-2019 Chris Pressey, Cat's Eye Technologies.
11 All rights reserved.
22
33 Redistribution and use in source and binary forms, with or without
00 Pail
11 ====
22
3 Pail is a programming language based on pairs; just as Lisp stands for
4 *LIS*t *P*rocessing, Pail stands for *PAI*r *L*anguage.
3 Pail is an esoteric programming language based on pairs; just as Lisp
4 stands for *LIS*t *P*rocessing, Pail stands for *PAI*r *L*anguage.
55
66 This is the reference distribution for Pail.
77
8 The Pail programming language is documented in the literate source code
9 of its reference interpreter, `Pail.lhs`, which can be found in the `src`
10 subdirectory. Some tests, in Falderal format, which might clarify the
11 intended behaviour can also be found in `Pail.markdown` in the `tests`
12 subdirectory.
8 The Pail programming language is documented in the literate Haskell
9 source code of its reference interpreter, `Pail.lhs`, which can be
10 found in the `src` subdirectory:
11
12 * [src/Pail.lhs](src/Pail.lhs)
13
14 Some tests, in [Falderal][] format, which might clarify the intended
15 behaviour, can be found in `Pail.markdown` in the `tests` subdirectory:
16
17 * [tests/Pail.markdown](tests/Pail.markdown)
1318
1419 These files are distributed under a 3-clause BSD license. See the file
1520 `LICENSE` for the license text.
1621
22 There is also a demonstration of running the Pail interpreter in
23 a web browser, by compiling the reference implementation to Javascript
24 with the [Haste][] compiler. You can try this locally by building
25 `demo/pail.js` and opening `demo/pail.html` in a web browser.
26
27 More information
28 ----------------
29
1730 For more information on the language, see the [Pail][] entry at
1831 Cat's Eye Technologies.
1932
20 [Pail]: http://catseye.tc/node/Pail
33 [Pail]: https://catseye.tc/node/Pail
34 [Falderal]: https://catseye.tc/node/Falderal
35 [Haste]: https://haste-lang.org/
0 #!/bin/sh
1
2 THIS=`realpath $0`
3 DIR=`dirname $THIS`
4 NAME=`basename $THIS`
5 SRC=$DIR/../src
6 if [ -x $DIR/$NAME.exe ] ; then
7 exec $DIR/$NAME.exe $*
8 elif command -v runhaskell 2>&1 >/dev/null ; then
9 exec runhaskell -i$SRC $SRC/Main.hs $*
10 elif command -v runhugs 2>&1 >/dev/null ; then
11 exec runhugs -i$SRC $SRC/Main.hs $*
12 else
13 echo "Cannot run $NAME; neither $NAME.exe, nor runhaskell, nor runhugs found."
14 exit 1
15 fi
0 #!/bin/sh
1
2 PROG=pail
3
4 if command -v ghc >/dev/null 2>&1; then
5 echo "building $PROG.exe with ghc"
6 (cd src && ghc --make Main.hs -o ../bin/$PROG.exe)
7 else
8 echo "ghc not found, not building $PROG.exe"
9 fi
10
11 # For this to work, you need hastec installed.
12 # You also need parsec installed in a way that haste can use it:
13 #
14 # haste-cabal install parsec-3.1.1
15 #
16 # Later versions might not work. For example, 3.1.13.0 fails to build for me at:
17 # Preprocessing library generic-deriving-1.12.3...
18 # src/Generics/Deriving/TH/Pre4_9.hs:177:20:
19 # parse error on input ‘->’
20 #
21
22 if command -v hastec >/dev/null 2>&1; then
23 echo "building $PROG.js with hastec"
24 (cd src && hastec --make HasteMain.hs -o ../demo/$PROG.js)
25 else
26 echo "hastec not found, not building $PROG.js"
27 fi
0 #!/bin/sh
1
2 rm -f src/*.hi src/*.o src/*.jsmod bin/*.exe
0 function launch(config) {
1 config.container.innerHTML = `
2 <textarea id="prog" rows="10" cols="80"></textarea>
3 <div id="control-panel"></div>
4 <div><button id="run-button">Run</button></div>
5 <pre id="result"></pre>
6 `;
7
8 function makeSelect(container, labelText, optionsArray, fun) {
9 var label = document.createElement('label');
10 label.innerHTML = labelText;
11 container.appendChild(label);
12 var select = document.createElement("select");
13 for (var i = 0; i < optionsArray.length; i++) {
14 var op = document.createElement("option");
15 op.text = optionsArray[i].filename;
16 op.value = optionsArray[i].contents;
17 select.options.add(op);
18 }
19 select.onchange = function(e) {
20 fun(optionsArray[select.selectedIndex]);
21 };
22 select.selectedIndex = 0;
23 label.appendChild(select);
24 return select;
25 };
26
27 function selectOptionByText(selectElem, text) {
28 var optElem;
29 for (var i = 0; optElem = selectElem.options[i]; i++) {
30 if (optElem.text === text) {
31 selectElem.selectedIndex = i;
32 selectElem.dispatchEvent(new Event('change'));
33 return;
34 }
35 }
36 }
37
38 var controlPanel = document.getElementById('control-panel');
39 var select = makeSelect(controlPanel, "example program:", examplePrograms, function(option) {
40 document.getElementById('prog').value = option.contents;
41 });
42 selectOptionByText(select, "apply-fun.pail");
43 }
44
45 launch({ container: document.getElementById('installation') });
0 <!DOCTYPE html>
1 <head>
2 <meta charset="utf-8">
3 <title>Pail</title>
4 </head>
5 <body>
6
7 <h1>Pail</h1>
8
9 <p>(Pail.hs compiled to .js by <code>hastec</code>, running in HTML5 document)</p>
10
11 <div id="installation"></div>
12
13 <script src="../eg/examplePrograms.jsonp.js"></script>
14 <script src="pail-hastec-launcher.js"></script>
15 <script src="pail.js"></script>
16 </body>
0 ***[#fst [a b]]
0 *[**[*fst [a b]] **[*snd [c d]]]
0 examplePrograms = [
1 {
2 "contents": "***[#fst [a b]]\n",
3 "filename": "apply-fun.pail"
4 },
5 {
6 "contents": "*[**[*fst [a b]] **[*snd [c d]]]\n",
7 "filename": "cons.pail"
8 },
9 {
10 "contents": "[#fst [a b]]\n",
11 "filename": "hash-sugar.pail"
12 },
13 {
14 "contents": "**[*let [[a b] *a]]\n",
15 "filename": "let-basic.pail"
16 },
17 {
18 "contents": "**[*let [\n [sndg *[**[*uneval snd] **[*uneval g]]]\n **[*let [\n [g [x y]]\n ***sndg\n ]]\n ]]\n",
19 "filename": "let-evaled.pail"
20 },
21 {
22 "contents": "**[*let [\n [g moo]\n **[*let [\n [consnull *[#g null]]\n ***consnull\n ]]\n ]]\n",
23 "filename": "let-unevaled.pail"
24 }
25 ];
0 [#fst [a b]]
0 **[*let [[a b] *a]]
0 **[*let [
1 [sndg *[**[*uneval snd] **[*uneval g]]]
2 **[*let [
3 [g [x y]]
4 ***sndg
5 ]]
6 ]]
0 **[*let [
1 [g moo]
2 **[*let [
3 [consnull *[#g null]]
4 ***consnull
5 ]]
6 ]]
0 module Main where
1
2 import Haste
3 import Haste.DOM
4 import Haste.Events
5
6 import Pail
7
8 main = withElems ["prog", "result", "run-button"] driver
9
10 escapeHTML "" = ""
11 escapeHTML ('<' : rest) = "&lt;" ++ escapeHTML rest
12 escapeHTML ('>' : rest) = "&gt;" ++ escapeHTML rest
13 escapeHTML ('&' : rest) = "&amp;" ++ escapeHTML rest
14 escapeHTML (c : rest) = (c : escapeHTML rest)
15
16 driver [progElem, resultElem, runButtonElem] = do
17 onEvent runButtonElem Click $ \_ -> execute
18 where
19 execute = do
20 Just prog <- getValue progElem
21 setProp resultElem "innerHTML" (escapeHTML $ runPail prog)
00 #!/bin/sh
11
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-body-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 RESULT=$?
29 rm -f fixture.markdown
30 exit $RESULT
2 APPLIANCES="tests/appliances/pail.md"
3 falderal $APPLIANCES tests/Pail.markdown
0 -> Functionality "Evaluate Pail Expression" is implemented by
1 -> shell command
2 -> "bin/pail %(test-body-file)"