-
Notifications
You must be signed in to change notification settings - Fork 0
/
first.sasq
32 lines (27 loc) · 939 Bytes
/
first.sasq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Math {
plus = (a: Int, b: Int): Int -> a + b
}
Option {
some = [T](value: T): { value: T } -> { value = value },
map = [T, U](option: { value: T }, mapper: { map: (input: T) -> U }): { value: U } -> { value = mapper.map(option.value) }
}
First {
use first/Math,
use first/Option,
use foreign java/io/File,
use foreign java/io/PrintStream,
use foreign java/lang/System,
gee = (arg: { bar: Int, foo: String }, otherArg: String): Void -> {
let toPrint = if (arg.bar > 0) arg.foo else otherArg
print toPrint
},
bar = (boo: String): String -> "doo",
main = (args: String[]): Void -> {
let third = { foo = "third", bar = 45 }
let optStr = Option.some("an option")
let optInt = Option.map(optStr, { map = (input: String): Int -> 10 })
print optInt.value
PrintStream#println(System#out, optInt.value)
gee(third, "testing")
}
}