PocketML`s syntax is largely based on Standard-ML and Haskell. Some quirks include:
;
let a = 10;
let b = 20;
print (a + b)
#
# i am a comment
A large part of PocketML is its editor.
Use the Editor
tab in the top toolbar
to edit files. Close files by long pressing the
file tab. Results show up in either
the Graphics
tab for graphics or the Text Out
tab for text output. The info box above the keyboard shows the type
of the symbol the cursor is on when clicked (no live type checking yet,
because the typechecker is too slow). Manage project files and directories
in the Files
tab. For advanced file management
use a File manager app that can access the
InternalStorage/Android/data/org.myapp.test/files/
directory. The Docs
tab provides a Hoogle-like interface for searching types, names or libraries.
PocketML has a set of builtin types: Vec (numpy arrays), Number, String, Bool, Tuples, Lists, Dict and Maybe. Num is an alias for Number and will replace it eventually.
The operators *, /, +, - support addition of strings, numbers, and Vecs, as long as both sides of the operator have the same type. The ° operator acts the same as *, but allows two different types to be multiplied (i.e. vector-scalar multiplication, string multiplication, etc.).
Operator | Type |
+,-,*,/ | a -> a -> a |
° | a -> b -> a |
composition operators: | |
<< | (y -> z) -> (x -> y) -> (x -> z) |
>> | (x -> y) -> (y -> z) -> (x -> z) |
$ | (x -> y) -> x -> y |
logical operators / equality: | |
&&, || | Bool -> Bool -> Bool |
<=, >=, <, > | Number -> Number -> Bool |
Most of the essentials are contained in the standard library lib.std
, but some basic functions are passed through from python directly:
Function | Type |
and,or | Bool -> Bool -> Bool |
add,sub,mul,pow | Number -> Number -> Number |
sqrt, inc, dec | Number -> Number |
True, False | Bool |
equal | a -> a -> Bool |
lt | Number -> Number -> Bool |
a -> () | |
print2 | a -> b -> () |