Glossary of System Functions






absvector _ Given a non-negative integer returns a vector in the native platform.
absvector? A --> boolean Recognisor for native vectors.
address-> _ Given an absolute vector A, a positive integer i
and a value V places V in the A[i]th position.
<-address _ Given an absolute vector A, a positive integer i
retrieves V from the A[i]th position.
adjoin A --> (list A) --> (list A) Conses an object to a list
if it is not already an element.
and boolean --> boolean --> boolean Boolean and.
append (list A) --> (list A) --> (list A) Appends two lists into one list.
Treated as polyadic. by the reader.
arity A --> number Given a symbol, returns the arity of the function it designates
otherwise -1.
atom? A --> boolean Recognisor for atoms, i.e. symbols, strings, numbers, booleans
and the empty list.
boolean? A --> boolean Recognisor for booleans.
bootstrap string --> string Given a filename to a Shen file pipes the Kλ code
from the Shen code; returns the filename with a kl extension.
bound? symbol --> boolean Returns true if the variable is globally bound.
call _ A unary higher-order Prolog predicate that calls its argument.
cd string --> string Changes the home directory. (cd "Prog") causes
(load "hello_world.txt") to load Prog/hello_world.txt.
(cd "") is the default.
char-stinput? (stream in) --> boolean Returns true if the input
is a character stream.
char-stoutput? (stream out) --> boolean Returns true if the input
is a character stream.
close (stream A) --> (list B) Closes a stream returning the empty list.
cn string --> string --> string Concatenates two strings.
compile (A ==> B) --> A --> B Applies a Shen YACC function to an input.
concat _ Concatenates two symbols or booleans.
cons _ A special form that takes an object e of type A
and a list l of type (list A) and produces a list of
type (list A) by adding e to the front of l.
cons? A --> boolean Returns true iff the input is a non-empty list.
declare _ Takes a function name f and a type t expressed as a list and gives f the type t.
destroy symbol --> symbol Receives the name of a function
and removes its type from the environment.
difference (list A) --> (list A) --> (list A) Subtracts the elements of the second list
from the first.
do A --> B --> B Returns its last argument;
polyadic courtesy of the reader.
element? A --> (list A) --> boolean Returns true iff the first input is an element in the second.
empty? A --> boolean Returns true iff the input is [ ].
enable-type-theory symbol --> boolean Takes + or - and enables/disables the Shen type system.
error _ A special form: takes a string followed by n (n --> 0) expressions.
Prints error string.
error-to-string exception --> string Maps an error message to the corresponding string.
eval _ Evaluates the input.
eval-kl _ Evaluates the input as a Kλ expression.
explode A --> (list string) Explodes an object to a list of strings.
external symbol --> (list symbol) Given a package name, returns the list of symbols
external to that package.
factorise symbol --> boolean Takes + or - and enables/dsiables code factorisation.
fail --> symbol Returns the failure object
– a symbol internal to the Shen package printed as ....
fix (A --> A) --> (A --> A) Applies a function to generate a fixpoint.
freeze A --> (lazy A) Returns a frozen version of its input.
fresh _ Generates a print vector which is printed as a unique integer
prefaced by &&t. This is used to generate arbitrary terms in type checking.
fst (A * B) --> A Returns the first element of a tuple.
gensym symbol --> symbol Generates a fresh symbol or variable from a symbol.
get-time symbol --> number For the argument run or real returns a number
representing the real or run time elapsed since the
last call. One of these options must be supported.
For the argument unix returns the Unix time.
get _ Takes a symbol S, a pointer P and optionally a vector V
and returns the value in V pointed by P from S (if one exists)
or an error otherwise. If V is omitted the global property vector is used.
hash A --> number --> number Returns a hashing of the first argument subject
to the restriction that the encoding must not be greater
than the second argument.
head (list A) --> A Returns the first element of a list;
if the list is empty returns an error.
hd _ Returns the first element of a list;
for [] the result is platform dependent.
hdstr string --> string Returns the first element of a string.
hdv (vector A) --> A Returns the first element of a standard vector.
if boolean --> A --> A --> A Takes a boolean b and two expressions x and y
and evaluates x if b evaluates to true
and evaluates y if b evaluates to false.
implementation --> string Returns a string denoting the implementation
on which Shen is running.
include (list symbol) --> (list symbol) Includes the datatype theories or synonyms for use in type checking.
include-all-but (list symbol) --> (list symbol) Includes all loaded datatype theories and synonyms
for use in type checking apart from those entered.
inferences --> number Returns the number of logical inferences executed
since the last call to the top level.
in-package symbol --> symbol Places the top level inside the package
denoted by the input and returns the input.
input _ 0-place function. Takes a user input i and returns the normal form of i.
input+ _ Special form. Takes inputs of the form .
If is not specified then defaults to standard input.
d() is the type denoted by the choice of expression
(e.g. ‘number’ denotes the type number). Takes a user input i
and returns the normal form of i given i is of the type d().
integer? A --> boolean Recognisor for integers.
intern _ Maps a string to a symbol.
1. Introduction

2. License

3. History

4. The Core Language

4.1 Base Types
4.1.1 Symbols
4.1.2 Strings
4.1.3 Numbers
4.2 Function Applications
4.3 The Top Level
4.4 Arithmetic

4.6 Sequences

4.6.1 Lists
4.6.2 Tuples
4.6.3 Vectors

4.7 lambda and let
4.8 Global Assignments
4.9 Higher Order Functions
4.10 Lazy Evaluation
4.11 I/O
4.12 Loading Files
4.13 Streams
4.14 Exceptions
4.15 Hashing
4.16 Property Lists
4.17 Eval

5 Defining Functions

5.1 Partial Functions
5.2 List Handling Functions
5.3 String Handling Functions
5.4 Tuple Handling Functions
5.5 Vector Handling Functions
5.6 Guards
5.7 Backtracking
5.8 Writing in Kλ
5.9 Macros

6. Packages

7. Shen-YACC

7.1 Recognisor Generator
7.2 Semantic Actions

8. Shen Prolog

8.1 Sample Programs

9. Types

9.1 Types and Constructors
9.2 Functions and Types
9.3 Synonyms

10 Sequent Calculus

10.1 Recursive Types

10.2 Exotic Types

10.2.1 Dependent Types
10.2.2 Negative Types
10.2.3 Subtypes
10.2.4 The Type of All Sets

11 Glossary of Functions

12 The Syntax of Shen

Built by Shen Technology (c) Mark Tarver, September 2021