Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource parZip & fromAutoCloseable #2452

Merged
merged 5 commits into from
Jul 26, 2021
Merged

Resource parZip & fromAutoCloseable #2452

merged 5 commits into from
Jul 26, 2021

Conversation

nomisRev
Copy link
Member

This PR adds:

  • First parallel operator for Resource parZip. This will allows for encoding parZip to arity-9, add parTraverseResource` etc.
  • a new constructor for Java's AutoCloseable, which was missing next to Closeable.
  • It updates the map operator to support suspend and adds tap combinator.

@nomisRev nomisRev requested review from a team and raulraja July 25, 2021 09:14
Copy link
Member

@raulraja raulraja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nomisRev !

public fun <B, C> parZip(fb: Resource<B>, f: (A, B) -> C): Resource<C> =
parZip(Dispatchers.Default, fb, f)

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should add similar comments with examples to other members in the data type that are public https://arrow-kt.io/docs/apidocs/arrow-fx-coroutines/arrow.fx.coroutines/-resource/map.html

public fun <A : Closeable> Resource.Companion.fromCloseable(f: suspend () -> A): Resource<A> =
Resource(f) { s, _ -> withContext(Dispatchers.IO) { s.close() } }

@Deprecated("Typo in the function name, use fromCloseable instead.", ReplaceWith("Resource.fromCloseable(f)"))
public fun <A : Closeable> Resource.Companion.fromClosable(f: suspend () -> A): Resource<A> =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅 Good eyes you have !!
Thanks👍🏾

Copy link
Member

@i-walker i-walker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nomisRev

@i-walker i-walker merged commit 3a5ad95 into main Jul 26, 2021
@i-walker i-walker deleted the sv-resource-parZip branch July 26, 2021 09:15
nomisRev added a commit that referenced this pull request Aug 2, 2021
* fix docs

* Add Resourc parZip

* Uncomment test, and remove deprecated usage

* Fix JS CancellationException ambiguity

* Replace shouldThrow with assertThrowable for JS runtime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants