Skip to content

Syntax Ideas

Joshua Pratt edited this page Aug 4, 2019 · 1 revision

Syntax

symbol
namespace.symbol

call
call()
call(kwA=symbol, kw2=symbol, remaining_arg_value)

definition = expr
definition(kw_name1, kw_name2, kw_name3=default_arg) = expr

def_expr = definition | definition, def_expr

expr = symbol
expr = def_expr
expr = definition | definition, expr
expr = expr op expr
op = oneof(+, -, *, /, ^, &, |, <<, >>, |>, <|, :, (,), !, <, <=, >=, !=, <>, ==, .)

precondition_expr = {precondition(args) -| expr}
postcondition_expr = {expr |- postcondition(args)}
prepostcondition_expr = {precondition(args) -| expr |- postcondition(args)}

Examples

Sys.out <| "Hello world!" <| Sys.endl

// Equivalent to
Sys.out("Hello world!")(Sys.endl)

// Equivalent to (because Sys.out(val) returns Sys.out)
Sys.out("Hello world!")
Sys.out(Sys.endl)

a = Sys.in |> getNumber

// Equivalent to
a = getNumber(Sys.in) 


a = map(f, listOfThings)
// Equivalent to
a = listOfThings |> map(f)

a = cat(map(f, listOfThings))
// Equivalent to
a = listOfThings |> map(f) |> cat

// Returns true if value a must conform to type t (in its current context)
a:t

e.g.
a = [1,2,3]
a:vector(int) == False
a:vector(number) == True
a:vector(int) == a[0]:int

Clone this wiki locally