Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== shen A port of the [[http://www.shenlanguage.org/|Shen programming language]] for Chicken Scheme. [[toc:]] === Shen [[http://www.shenlanguage.org/|Shen]] is a hosted language that comes with a macro system, optional type system based on [[https://en.wikipedia.org/wiki/Sequent_calculus|sequent calculus]], pattern matching, [[https://en.wikipedia.org/wiki/Lambda_calculus|λ calculus]] consistency, optional lazy evaluation, an integrated [[https://en.wikipedia.org/wiki/Prolog|Prolog]] and [[https://en.wikipedia.org/wiki/Compiler-compiler|compiler-compiler]]. This egg comes with a standalone binary ''chicken-shen'' that provides a REPL and a library to use Shen inside Scheme. === Egg Author David Ireland (djireland79 at gmail dot com) === Shen Documentation The best source of information for Shen programming is [[https://www.amazon.com/Book-Shen-third-Mark-Tarver/dp/1784562130/ref=sr_1_1?ie=UTF8&qid=1548832486&sr=8-1&keywords=the+book+of+shen| The Book of Shen]], [[https://www.amazon.com/Logic-Proof-Computation-Mark-Tarver/dp/1784561274|Logic, Proof and Computation]] and the [[http://www.shenlanguage.org/|Shen web site]] . === Egg Source Code [[https://code.sarnath.xyz/chicken-shen |Chicken-Shen]] === Chicken Shen Usage Usage for the standalone binary for running a REPL or loading a file or string is here: <enscript highlight="bash"> $ chicken-shen -h </enscript> <enscript highlight="bash"> Usage: shen [options] [...args...] -h, --help : Prints help and exits -l, --load <file> : Loads Shen <file> -e, --eval <string> : Evaluates <string> -r, --repl : Run the REPL, even if -l or -e are provided Any additional arguments are passed to the Shen system in the variable shen-chicken.*argv* </enscript> ==== Starting the REPL from a terminal <enscript highlight="bash"> $ chicken-shen -r </enscript> <enscript highlight="bash"> Shen, copyright (C) 2010-2015 Mark Tarver www.shenlanguage.org, Shen 21.1 running under Scheme, implementation: Chicken port 0.1 ported by David Ireland (0-) </enscript> === Calling Shen from Scheme <procedure> (run-shen) </procedure> Runs the REPL inside Chicken Scheme <procedure> (read-file FILE) </procedure> Reads and loads a Shen file <procedure> (read-from-string STRING) </procedure> Reads and loads a string containing Shen code. <enscript highlight="lisp"> (import (prefix shen shen:)) ;;; Load file example (shen:read-file "foo.shen") ;;; Evaluate string (shen:read-from-string "(define foo 0 -> 1 1 -> 0)") (shen:read-from-string "(foo 0)") ;;; Should return 1 </enscript> === Example Shen Code ==== Symbols Unlike Chicken Scheme symbols are implicitly quoted thus no ' is needed. <enscript highlight="lisp"> (0-) HI HI </enscript> ==== Basic List processing Lists in Shen are enclosed with [ ] for example: <enscript highlight="lisp"> (12-) [1 2 3] (13-) (head [1 2 3]) 1 (14-) (cons 1 []) [1] (15-) [1 2 | [3]] [1 2 3] </enscript> ==== Procedures Procedures are defined using a pattern matching. For example: <enscript highlight="lisp"> (define factorial 0 -> 1 X -> (* X (factorial (- X 1)))) </enscript> <enscript highlight="lisp"> (define total [] -> 0 [X | Y] -> (+ X (total Y))) </enscript> <enscript highlight="lisp"> (define triples [] -> [] [W X Y | Z] -> [[W X Y] | (triples Z)]) </enscript> ==== YACC Shen has an internal YACC (yet another compiler compiler) <enscript highlight="lisp"> (defcc <binary?> X <binary?> := true where (element? X [0 1]); X := true where (element? X [0 1]); <e> := false;) </enscript> ==== Prolog Shen also has an embedded Prolog for logic programming <enscript highlight="lisp"> (defprolog member xxX [X | _] <--; xxX [_ | Y] <-- (member X Y);) </enscript> ==== Type System The type system is optional and disabled by default. It can be enabled using: <enscript highlight="lisp"> (0-) (tc +) true (1+) 5 5 : number (2+) "ABC" "ABC" : string (3+) (+ 1 1) 2 : number </enscript> and off with: <enscript highlight="lisp"> (4+) (tc -) false : boolean (5-) 5 5 (6-) "ABC" "ABC" (7-) (+ 1 1) 2 </enscript> ==== Calling Scheme from Shen Calling native Chicken procedures is done by prefixing 'lisp' to the procedure name. An example of calling Chicken's print is given below. <enscript highlight="bash"> Shen, copyright (C) 2010-2015 Mark Tarver www.shenlanguage.org, Shen 21.1 running under Scheme, implementation: Chicken port 0.1 ported by David Ireland (0-) (lisp.print "Hello World") Hello World #<unspecified> (1-) </enscript> === About this egg ==== License BSD Clause 3 ==== Dependencies srfi-1 srfi-13 ==== Versions
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 0 by 8?