Pattern Calculus is a book by Dr. Barry Jay a lecturer at UTS. It features a language based on, ML called Bondi. Below are is some documentation I created for this language.
API
Types
- Unit
- Ref
- Int
- Float
- String
- Char
- Cons
- BinProd
- Konstant (seriously?)
- Identity
- ParamProduct
- Okay
- Nested
- Represent
- Maybe
Infix Functions
name | use | description |
[String] ^ [String] | Concatenates two strings | |
concat | [String] concat [String] | Concatenates two strings |
plusint | [Int] plusint [Int] | |
plusfloat | [Float] plusfloat [Float] | |
shotplus | [Num] shortplus [Num] | Adds two numbers (or lists of numbers) of the same type. |
minus | [Num] minus [Num] | Subtracts two numbers (or lists of numbers) of the same type. |
times | [Num] times [Num] | Multiply two numbers (or lists of numbers) of the same type. |
divide | [Num] divide [Num] | Divide two numbers (or lists of numbers) of the same type. |
negate | negate [Num] | Convert a number (or list of numbers) to its negative. |
lessthan | [Val] lessthan [Val] | Returns true if first value is less than second. |
lessthanorequal | [Val] lessthanorequal [Val] | Returns true if first value is less or equal to second. |
greaterthan | [Val] greaterthan [Val] | Returns true if first value is greater than second. |
greaterthanorequal | [Val] greaterthanorequal [Val] | Returns true if first value is greater or equal to second. |
equal | [arg] equal [arg] | Equals operator. |
+ | [Num] + [Num] | Adds two numbers (or lists of numbers) of the same type. |
- | [Num] - [Num] | Subtracts two numbers (or lists of numbers) of the same type. |
- | -[Num] | Declares a numbers as negative. |
* | [Num] * [Num] | Multiply two numbers (or lists of numbers) of the same type. |
/ | [Num] / [Num] | Divide two numbers (or lists of numbers) of the same type. |
&& | [arg] && [arg] | AND boolean operator |
|| | [arg] || [arg] | OR boolean operator |
== | [arg] == [arg] | Equals operator. |
: | [wildcard] : [Type] | Declares that the wild card will be of [Type]. This can only be used in pattern matching. |
: | [function name] : [Type1] -> [Type2] | Declares that the function will take an argument of Type 1 and return an argument of Type 2 |
< | [Val] [ [Val] | Returns true if first value is less than second. |
<= | [Val] [= [Val] | Returns true if first value is less or equal to second. |
> | [Val] > [Val] | Returns true if first value is greater than second. |
>= | [Val] >= [Val] | Returns true if first value is greater or equal to second. |
; | ||
-> | ||
[] | [] | Returns Nil |
[] | [[arg1],[arg2],[function][arg3]] | Returns a list of args, evaluating any unseparated functions. Lists can only contain one type of argument. Unknown if inheritance applies at this stage. |
() | () | Absolutely nothing. |
() | ([function][arg] [arg]) | Executes functions in parens before other functions |
() | ([function],[arg],[arg]) | Creates a cons list of the listed arguments |
() | ([function][arg],[arg]) | Evaluates function on arg, and returns a list of the comma separated args. |
() | ((((([function][arg]))))) | Returns the value of function |
Functions
name | use | description |
not | not [arg] | Should be obvious. |
toString | toString [arg] | Converts the argument into a string. |
print [arg] | Prints arg as string | |
println | println [arg] | prints arg on new line |
forall | forall [low][high] [function] | Apply function on all in range. |
iter | iter [Function][Par] | NFI |
plus | plus [List of two numbers OR List of Two Even lists of numbers] | Either adds the two numbers together, or creates a new list of added numbers |
clone [& args] | Performs a shallow clone of arguments using divide and conquer | |
let | let [rec/ext][varname] = [Term][optional in] | Define global variables. Rec indicates recursion allowed, ext = NFI, in causes let to have temporary scope. |
apply2all | apply2all [function][AnyArgs] | Currently, NFI |
datatype | datatype [Name][& args] = [Type] of [& args] and [Type] of [& args] and [& args] | Create a new Type with the listed arguments, and define types of its arguments. The "and", "of" and "=" keywords are required syntactic sugar. |
fst | fst [Tuple] | Returns the first element of a Tuple |
snd | snd [Tuple] | Returns the second element of a Tuple |
deconstruct | decconstruct | NFI |
reconstruct | reconstruct | NFI |
map | map [function][A deconstructable type] | Create a clone of a datastruction with all arguments changed by the mapped function. |
while | while [boolean] do [function] else [function] | While loop. |
fun | fun [& args] -> [function definition] | Create a lambda function. |
foldleft | foldleft [function][arg1] [List] | Performs a recursive reduce, consuming the fist element in List until empty. |
foldright | foldright [function][arg1] [List] | peforms a recursive reduce, consuming the last element of List until empty. |
zipwith | zipwith [function][List containing Lists] | Creates a new list by mapping the function on the nth value in each list. |