You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ace8e90
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+21-9Lines changed: 21 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,19 @@
5
5
6
6
Functional patterns for Java 8
7
7
8
-
Background
8
+
#### Table of Contents
9
+
10
+
-[Background](#background)
11
+
-[Installation](#installation)
12
+
-[Examples](#examples)
13
+
-[ADTs](#adts)
14
+
-[HLists](#hlists)
15
+
-[Tuples](#tuples)
16
+
-[HMaps](#hmaps)
17
+
-[Either](#either)
18
+
-[License](#license)
19
+
20
+
<aname="background">Background</a>
9
21
----------
10
22
11
23
Lambda was born out of a desire to use some of the same canonical functions (e.g. `unfoldr`, `takeWhile`, `zipWith`) and functional patterns (e.g. `Functor` and friends) that are idiomatic in other languages and make them available for Java.
@@ -22,7 +34,7 @@ Generally, everything that lambda produces is lazily-evaluated (except for termi
22
34
23
35
Although the library is currently (very) small, these values should always be the driving forces behind future growth.
24
36
25
-
Installation
37
+
<aname="installation">Installation</a>
26
38
------------
27
39
28
40
Add the following dependency to your:
@@ -44,7 +56,7 @@ Add the following dependency to your:
44
56
```
45
57
46
58
47
-
Examples
59
+
<aname="examples">Examples</a>
48
60
--------
49
61
50
62
First, the obligatory `map`/`filter`/`reduce` example:
@@ -124,12 +136,12 @@ And have fun with 3s:
124
136
125
137
Check out the [tests](https://github.com/palatable/lambda/tree/master/src/test/java/com/jnape/palatable/lambda/functions/builtin) or [javadoc](http://palatable.github.io/lambda/javadoc/) for more examples.
126
138
127
-
ADTs
139
+
<aname="adts">ADTs</a>
128
140
----
129
141
130
142
In addition to the functions above, lambda also supports a few first-class [algebraic data types](https://www.wikiwand.com/en/Algebraic_data_type).
HLists are type-safe heterogeneous lists, meaning they can store elements of different types in the same list while facilitating certain type-safe interactions.
135
147
@@ -145,7 +157,7 @@ The following illustrates how the linear expansion of the recursive type signatu
145
157
//nil.head() won't type-check
146
158
```
147
159
148
-
#### Tuples
160
+
#### <aname="tuples">Tuples</a>
149
161
150
162
One of the primary downsides to using `HList`s in Java is how quickly the type signature grows.
151
163
@@ -188,7 +200,7 @@ Finally, all `Tuple*` classes are instances of both `Functor` and `Bifunctor`:
188
200
System.out.println(mappedTuple3._3()); // prints 2
189
201
```
190
202
191
-
### Heterogeneous Maps
203
+
### <aname="hmaps">Heterogeneous Maps</a>
192
204
193
205
HMaps are type-safe heterogeneous maps, meaning they can store mappings to different value types in the same map; however, whereas HLists encode value types in their type signatures, HMaps rely on the keys to encode the value type that they point to.
194
206
@@ -203,7 +215,7 @@ HMaps are type-safe heterogeneous maps, meaning they can store mappings to diffe
Binary tagged unions are represented as `Either<L, R>`s, which resolve to one of two possible values: a `Left` value wrapping an `L`, or a `Right` value wrapping an `R` (typically an exceptional value or a successful value, respectively).
209
221
@@ -222,7 +234,7 @@ Rather than supporting explicit value unwrapping, `Either` supports many useful
222
234
223
235
Check out the tests for [more examples](https://github.com/palatable/lambda/blob/master/src/test/java/com/jnape/palatable/lambda/adt/EitherTest.java) of ways to interact with `Either`.
224
236
225
-
License
237
+
<aname="license">License</a>
226
238
-------
227
239
228
240
_lambda_ is part of [palatable](http://www.github.com/palatable), which is distributed under [The MIT License](http://choosealicense.com/licenses/mit/).
0 commit comments