Skip to content

Commit 5c1f3c6

Browse files
committed
format: align-under-arg0 for short arg0s, +2 nest for compound arg0s; sum-type deftype + multi-body defmodule stay multi-line; comments in bindings preserve pair-awareness; arrays start first item on opening line
1 parent 5f285ef commit 5c1f3c6

4 files changed

Lines changed: 20 additions & 18 deletions

File tree

impl/hompair.carp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
(defn lookup [pair] (fn [i] (Hompair.nth &pair i)))
1818

1919
(sig map
20-
(Fn [(Ref (Fn [a] b)) (Ref (Hompair (Size.size 2) a))]
21-
(Hompair (Size.size 2) b)))
20+
(Fn
21+
[(Ref (Fn [a] b)) (Ref (Hompair (Size.size 2) a))]
22+
(Hompair (Size.size 2) b)))
2223
(implements smap map)
2324
(defn map [f pair]
2425
(let [first (~f @(Hompair.first pair))

src/hompair.carp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
""
99
"Hompairs implement the [dimensional interfaces](dimensional.html).")
1010
(deftype (Hompair s a) [first a
11-
second a])
11+
second a])
1212
(hidden Hompair.init)
1313
(private Hompair.init)
1414

@@ -44,10 +44,10 @@
4444
"=> 1"
4545
"```")
4646
(sig nth
47-
(Fn [
48-
(Ref (Hompair (Size.size 2) a))
49-
(Index (Hompair (Size.size 2) Opaque) Int)]
50-
a))
47+
(Fn
48+
[(Ref (Hompair (Size.size 2) a))
49+
(Index (Hompair (Size.size 2) Opaque) Int)]
50+
a))
5151
(defn nth [pair index]
5252
(if (= 0 (to-int &index)) @(Hompair.first pair) @(Hompair.second pair)))
5353

@@ -91,5 +91,6 @@
9191

9292
(implements = ref=)
9393
(defn ref= [pair other-pair]
94-
(and (= @(Hompair.first pair) @(Hompair.first other-pair))
95-
(= @(Hompair.second pair) @(Hompair.second other-pair)))))
94+
(and
95+
(= @(Hompair.first pair) @(Hompair.first other-pair))
96+
(= @(Hompair.second pair) @(Hompair.second other-pair)))))

src/vector.carp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040

4141
(doc zip "Combines two Vectors using a binary function `f`.")
4242
(sig zip
43-
(Fn [(Ref (Fn [a b] c)) (Ref (Vector n a)) (Ref (Vector n b))]
44-
(Vector n c)))
43+
(Fn
44+
[(Ref (Fn [a b] c)) (Ref (Vector n a)) (Ref (Vector n b))]
45+
(Vector n c)))
4546
(defn zip [f v v1]
4647
(let [copy-then-apply (fn [a b] (~f @a @b))
4748
arr (Vector.elements v)
@@ -64,20 +65,21 @@
6465
(sig last (Fn [(Ref (Vector (Size n) a))] a))
6566
(defn last [v]
6667
@(Array.unsafe-nth (Vector.elements v)
67-
(to-int (the (Phantom n) (Phantom.init)))))
68+
(to-int (the (Phantom n) (Phantom.init)))))
6869

6970
(doc head "Returns the first element of a Vector.")
7071
(sig head (Fn [(Ref (Vector (Size n) a))] a))
7172
(defn head [v]
7273
@(Array.unsafe-nth (Vector.elements v)
73-
(to-int (the (Phantom Zero) (Phantom.init)))))
74+
(to-int (the (Phantom Zero) (Phantom.init)))))
7475

7576
(hidden gen-vec)
7677
(defndynamic gen-vec [vs acc]
7778
(if (= 0 (length vs))
7879
acc
7980
(Vector.gen-vec (cdr vs)
80-
(cons-last (list 'Vector.push (car vs)) (cons-last '(ref) acc)))))
81+
(cons-last (list 'Vector.push (car vs))
82+
(cons-last '(ref) acc)))))
8183

8284
(doc of "Creates a new Vector from the contents of an Array literal.")
8385
(defmacro of [values]

test/vector-impl.carp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
"lookup returns the element at a given index")
1515
(assert-equal test
1616
&(Vector.of [(Vector.of [1 3 5]) (Vector.of [2 4 6])])
17-
&(Dimensional.transpose &(Vector.of [
18-
(Vector.of [1 2])
19-
(Vector.of [3 4])
20-
(Vector.of [5 6])]))
17+
&(Dimensional.transpose
18+
&(Vector.of [(Vector.of [1 2]) (Vector.of [3 4]) (Vector.of [5 6])]))
2119
"transpose swaps the sizes of a Vector of Vectors"))

0 commit comments

Comments
 (0)