Skip to content

Commit 727aa99

Browse files
authored
Merge pull request #2 from ArkScript-lang/feat-doc
Feat doc
2 parents 2a04d60 + 908b858 commit 727aa99

36 files changed

+804
-400
lines changed

Exceptions.ark

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
###
2+
# @meta Exceptions
3+
# @brief throw takes a value as its argument and return it to be used by try
4+
# ---
5+
# (let error (throw "cannot divide by zero"))
6+
# ---
7+
# @param _x the value to return
8+
# @author https://github.com/SuperFola
9+
###
10+
(let throw (fun (_x)
11+
(fun (_injl _injr &_x) (_injl _x))
12+
))
13+
14+
###
15+
# @meta Exceptions
16+
# @brief return takes a value as its argument and return it to be used by try
17+
# ---
18+
# (let value (return (/ 1 x)))
19+
# ---
20+
# @param _x the value to return
21+
# @author https://github.com/SuperFola
22+
###
23+
(let return (fun (_y)
24+
(fun (_injl _injr &_y) (_injr _y))
25+
))
26+
27+
###
28+
# @meta Exceptions
29+
# @brief Takes a value either returned by throw or return and apply a given on it if it's an error or not
30+
# ---
31+
# (let invert (fun (x)
32+
# (if (= x 0)
33+
# (throw "cannot divide by zero")
34+
# (return (/ 1 x)))))
35+
# (try (invert 0)
36+
# (fun (inverted) (print inverted))
37+
# (fun (err) (print err)))
38+
# ---
39+
# @param _either the value to test
40+
# @param _continue the success handler
41+
# @param _handle the error handler
42+
# @author https://github.com/SuperFola
43+
###
44+
(let try (fun (_either _continue _handle)
45+
(_either _handle _continue)))

Functional.ark

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
###
2+
# @meta Functional
3+
# @brief Compose function calls
4+
# ---
5+
# (let foo (fun (a) (* a a)))
6+
# (let bar (fun (b) (+ b b)))
7+
# (let composed (compose foo bar))
8+
# (print (composed 12)) # return value is (12 + 12) * (12 + 12)
9+
# ---
10+
# @param _f the first function
11+
# @param _g the second function
12+
# @author https://github.com/rstefanic
13+
###
14+
(let compose (fun (_f _g)
15+
(fun (_y &_f &_g) (_f (_g _y)))))
16+
17+
###
18+
# @meta Functional
19+
# @brief Take a value as its argument and return a function taking 2 arguments which will call the first function on the value
20+
# ---
21+
# (let val (left 12))
22+
# (val (fun (x) (print x " i am called")) (fun (x) (print x " i am NOT called")))
23+
# ---
24+
# @param _x the value
25+
# @author https://github.com/SuperFola
26+
###
27+
(let left (fun (_x)
28+
(fun (_injl _injr &_x) (_injl _x))
29+
))
30+
31+
###
32+
# @meta Functional
33+
# @brief Take a value as its argument and return a function taking 2 arguments which will call the second function on the value
34+
# ---
35+
# (let val (right 12))
36+
# (val (fun (x) (print x " i am NOT called")) (fun (x) (print x " i am called")))
37+
# ---
38+
# @param _y the value
39+
# @author https://github.com/SuperFola
40+
###
41+
(let right (fun (_y)
42+
(fun (_injl _injr &_y) (_injr _y))
43+
))
44+
45+
###
46+
# @meta Functional
47+
# @brief Flip the arguments of a function
48+
# @details Returns a function taking 1 argument: the second argument of the function to flip
49+
# ---
50+
# (let foo (fun (a b) (- a b)))
51+
# ((flip foo 14) 12) # will call (foo 12 14) instead of (foo 14 12)
52+
# ---
53+
# @param _f the function
54+
# @param _a the first argument
55+
# @author https://github.com/rstefanic
56+
###
57+
(let flip (fun (_f _a)
58+
(fun (_b &_f &_a) (_f _b _a))))

Functional/Compose.ark

Lines changed: 0 additions & 2 deletions
This file was deleted.

Functional/Drop.ark

Lines changed: 0 additions & 9 deletions
This file was deleted.

Functional/DropWhile.ark

Lines changed: 0 additions & 14 deletions
This file was deleted.

Functional/Either.ark

Lines changed: 0 additions & 8 deletions
This file was deleted.

Functional/Exceptions.ark

Lines changed: 0 additions & 8 deletions
This file was deleted.

Functional/Filter.ark

Lines changed: 0 additions & 11 deletions
This file was deleted.

Functional/Flip.ark

Lines changed: 0 additions & 2 deletions
This file was deleted.

Functional/Functional.ark

Lines changed: 0 additions & 14 deletions
This file was deleted.

Functional/Map.ark

Lines changed: 0 additions & 9 deletions
This file was deleted.

Functional/Reduce.ark

Lines changed: 0 additions & 9 deletions
This file was deleted.

Functional/Take.ark

Lines changed: 0 additions & 9 deletions
This file was deleted.

Functional/TakeWhile.ark

Lines changed: 0 additions & 15 deletions
This file was deleted.

Functional/Unzip.ark

Lines changed: 0 additions & 13 deletions
This file was deleted.

Functional/Zip.ark

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)