{"action":"created","issue":{"url":"https://api.github.com/repos/rocketscience-projects/javaslang/issues/131","labels_url":"https://api.github.com/repos/rocketscience-projects/javaslang/issues/131/labels{/name}","comments_url":"https://api.github.com/repos/rocketscience-projects/javaslang/issues/131/comments","events_url":"https://api.github.com/repos/rocketscience-projects/javaslang/issues/131/events","html_url":"https://github.com/rocketscience-projects/javaslang/issues/131","id":67458198,"number":131,"title":"Add Valences.{Univalent, Bivalent}.peek() and Traversable.peek()","user":{"login":"danieldietrich","id":743833,"avatar_url":"https://avatars.githubusercontent.com/u/743833?v=3","gravatar_id":"","url":"https://api.github.com/users/danieldietrich","html_url":"https://github.com/danieldietrich","followers_url":"https://api.github.com/users/danieldietrich/followers","following_url":"https://api.github.com/users/danieldietrich/following{/other_user}","gists_url":"https://api.github.com/users/danieldietrich/gists{/gist_id}","starred_url":"https://api.github.com/users/danieldietrich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danieldietrich/subscriptions","organizations_url":"https://api.github.com/users/danieldietrich/orgs","repos_url":"https://api.github.com/users/danieldietrich/repos","events_url":"https://api.github.com/users/danieldietrich/events{/privacy}","received_events_url":"https://api.github.com/users/danieldietrich/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rocketscience-projects/javaslang/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/rocketscience-projects/javaslang/labels/[collection]","name":"[collection]","color":"d4c5f9"},{"url":"https://api.github.com/repos/rocketscience-projects/javaslang/labels/[control]","name":"[control]","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/rocketscience-projects/javaslang/milestones/15","html_url":"https://github.com/rocketscience-projects/javaslang/milestones/1.3.0%20Stream","labels_url":"https://api.github.com/repos/rocketscience-projects/javaslang/milestones/15/labels","id":929759,"number":15,"title":"1.3.0 Stream","description":"Implement non-blocking streams as lazy linked lists based on Iteratee/Enumerator.","creator":{"login":"danieldietrich","id":743833,"avatar_url":"https://avatars.githubusercontent.com/u/743833?v=3","gravatar_id":"","url":"https://api.github.com/users/danieldietrich","html_url":"https://github.com/danieldietrich","followers_url":"https://api.github.com/users/danieldietrich/followers","following_url":"https://api.github.com/users/danieldietrich/following{/other_user}","gists_url":"https://api.github.com/users/danieldietrich/gists{/gist_id}","starred_url":"https://api.github.com/users/danieldietrich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danieldietrich/subscriptions","organizations_url":"https://api.github.com/users/danieldietrich/orgs","repos_url":"https://api.github.com/users/danieldietrich/repos","events_url":"https://api.github.com/users/danieldietrich/events{/privacy}","received_events_url":"https://api.github.com/users/danieldietrich/received_events","type":"User","site_admin":false},"open_issues":21,"closed_issues":3,"state":"open","created_at":"2015-01-10T13:27:45Z","updated_at":"2015-04-09T22:15:27Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-04-09T21:47:29Z","updated_at":"2015-04-10T07:41:18Z","closed_at":null,"body":"@ggalmazor suggested: \"Maybe we could also benefit from something like Try.peek() (as in Stream.peek()) to support side effects on a map/filter pipeline. This would be helpful with objects like the one from your example whose methods don't return themselves (impeding their use on map() phases in the pipeline).\""},"comment":{"url":"https://api.github.com/repos/rocketscience-projects/javaslang/issues/comments/91468750","html_url":"https://github.com/rocketscience-projects/javaslang/issues/131#issuecomment-91468750","issue_url":"https://api.github.com/repos/rocketscience-projects/javaslang/issues/131","id":91468750,"user":{"login":"danieldietrich","id":743833,"avatar_url":"https://avatars.githubusercontent.com/u/743833?v=3","gravatar_id":"","url":"https://api.github.com/users/danieldietrich","html_url":"https://github.com/danieldietrich","followers_url":"https://api.github.com/users/danieldietrich/followers","following_url":"https://api.github.com/users/danieldietrich/following{/other_user}","gists_url":"https://api.github.com/users/danieldietrich/gists{/gist_id}","starred_url":"https://api.github.com/users/danieldietrich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danieldietrich/subscriptions","organizations_url":"https://api.github.com/users/danieldietrich/orgs","repos_url":"https://api.github.com/users/danieldietrich/repos","events_url":"https://api.github.com/users/danieldietrich/events{/privacy}","received_events_url":"https://api.github.com/users/danieldietrich/received_events","type":"User","site_admin":false},"created_at":"2015-04-10T07:41:18Z","updated_at":"2015-04-10T07:41:18Z","body":"Thank you, great example.\r\n\r\nGiven an object `o` of type `A<T>` we would define `peek : (T -> void) -> A<T>`, i.e.\r\n\r\n```java\r\ninterface Peekable<T> {\r\n    Peekable<T> peek(Consumer<T> action);\r\n}\r\n```\r\n\r\nTry is a special case. Here we would expect  a `CheckedConsumer` instead.\r\n\r\nThe semantics of peek depends on the data type. However, in each case it will return the instance it was called on. Additionally the value passed to the consumer is determined as follows:\r\n\r\n* Try: the value of Success (or nothing happens)\r\n* Option: the value of Some (or nothing happens)\r\n* Either: the value of either left or right in the context of a left or right projection (or nothing happens in the context of the opposite projection)\r\n* List: the head element or NoSuchElementException on the empty list. Perhaps additionally a `List<T> peekOption(Consumer<Option<T>> action)` which does not throw when called on Nil\r\n* Stream: currently unclear because 1.3.0 may change Stream significantly. Most probably the intermediate operations are deferred in a pipeline of operations. A lazily requested element will walk through the pipeline. Given this, peek will not only called eagerly on the head element but also for all elements of the stream - like in java.util.stream.Stream\r\n\r\nSounds like a plan!"}}