-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9278f1b
commit 16354ae
Showing
6 changed files
with
68 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 11 additions & 15 deletions
26
src/main/java/ca/genovese/coffeecats/data/eval/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,26 @@ | ||
/** | ||
* Eval is a monad which controls evaluation. | ||
* <p> | ||
* This type wraps a value (or a computation that produces a value) | ||
* <p>This type wraps a value (or a computation that produces a value) | ||
* and can produce it on command via the `.value()` method. | ||
* <p> | ||
* There are three basic evaluation strategies: | ||
* <p> | ||
* - Now: evaluated immediately | ||
* - Later: evaluated once when value is needed | ||
* - Always: evaluated every time value is needed | ||
* <p> | ||
* The Later and Always are both lazy strategies while Now is eager. | ||
* <p>There are three basic evaluation strategies: | ||
* <ul> | ||
* <li>Now: evaluated immediately</li> | ||
* <li>- Later: evaluated once when value is needed</li> | ||
* <li>- Always: evaluated every time value is needed</li> | ||
* </ul> | ||
* <p>The Later and Always are both lazy strategies while Now is eager. | ||
* Later and Always are distinguished from each other only by | ||
* memoization: once evaluated Later will save the value to be returned | ||
* immediately if it is needed again. Always will run its computation | ||
* every time. | ||
* <p> | ||
* Eval supports stack-safe lazy computation via the .map and .flatMap | ||
* <p>Eval supports stack-safe lazy computation via the .map and .flatMap | ||
* methods, which use an internal trampoline to avoid stack overflows. | ||
* Computation done within .map and .flatMap is always done lazily, | ||
* even when applied to a Now instance. | ||
* <p> | ||
* Use .map and .flatMap to chain computation, and use .value | ||
* <p>Use .map and .flatMap to chain computation, and use .value | ||
* to get the result when needed. It is not good style to create | ||
* Eval instances whose computation involves calling .value on another | ||
* Eval instance -- this can defeat the trampolining and lead to stack | ||
* overflows. | ||
*/ | ||
package ca.genovese.coffeecats.data.eval; | ||
package ca.genovese.coffeecats.data.eval; |