Skip to content

Commit

Permalink
Merge pull request #553 from kevin-lee/prepare-to-release
Browse files Browse the repository at this point in the history
effectie v2.0.0-beta10
  • Loading branch information
kevin-lee authored Jul 15, 2023
2 parents 66b76f7 + 6b0371f commit a3e18da
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 1 deletion.
111 changes: 111 additions & 0 deletions changelogs/2.0.0-beta10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
## [2.0.0-beta10](https://github.com/Kevin-Lee/effectie/issues?q=is%3Aissue+is%3Aclosed+milestone%3Av2-m1+closed%3A2023-03-19..2023-07-15) - 2023-07-15

### New Feature

* Add `fromEffect(fa: => F[A]): F[A]` to `FxCtor` and `Fx` (#524)
```scala
Fx[IO].fromEffect(IO(1)) // IO[Int]
FxCtor[IO].fromEffect(IO(1)) // IO[Int]
```


* Add `make[A](fa: => F[A])(release: A => F[Unit]): ReleasableResource[F, A]` to `ResourceMaker[F[*]]` (#527)
```scala
def make[A](fa: => F[A])(release: A => F[Unit]): ReleasableResource[F, A]
```

* `Try`
```scala
val resourceMaker = ResourceMaker.usingResourceMaker
resourceMaker
.make(Try(new SomeResource()))(a => Try(a.release())) // ReleasableResource[Try, SomeResource]
.use { someResource =>
// do something with someResource
Try(result) // Try[ResultType]
} // Try[ResultType]
```

* Future
```scala
val resourceMaker = ResourceMaker.futureResourceMaker
resourceMaker
.make(Future(new SomeResource()))(a => Future(a.release())) // ReleasableResource[Future, SomeResource]
.use { someResource =>
// do something with someResource
Future.successful(result) // Future[ResultType]
} // Future[ResultType]
```

* Cats Effect 2
```scala
val resourceMaker = Ce2ResourceMaker.withResource
resourceMaker
.make(IO(new SomeResource()))(a => IO(a.release())) // ReleasableResource[IO, SomeResource]
.use { someResource =>
// do something with someResource
IO.pure(result) // IO[ResultType]
} // IO[ResultType]
```

* Cats Effect 3
```scala
val resourceMaker = Ce3ResourceMaker.withResource
resourceMaker
.make(IO(new SomeResource()))(a => IO(a.release())) // ReleasableResource[IO, SomeResource]
.use { someResource =>
// do something with someResource
IO.pure(result) // IO[ResultType]
} // IO[ResultType]
```


* Add `pure[A](a: A)` and `eval[A](fa: F[A])` to `ResourceMaker` (#534)
```scala
trait ResourceMaker[F[*]] {
...

def pure[A](a: A): ReleasableResource[F, A]

def eval[A](fa: F[A]): ReleasableResource[F, A]
}
```


* Add `ReleasableResource.pure` (#542)
```scala
ReleasableResource.pure(resource: A): ReleasableResource[F, A]
```
So `A` doesn't have to be `AutoCloseable` as it's just a pure value.


* Add `ReleasableResource.map` and `ReleasableResource.flatMap` (#544)
```scala
ReleasableResource.map(f: A => B)
ReleasableResource.flatMap(f: A => ReleasableResource[F, B])
```


* Add `Functor` type-class for `ReleasableResource` (#548)


* Add `Applicative` type-class for `ReleasableResource` (#550)



### Changes

* Remove unnecessary re-evaluation of `ResourceMaker` (#529)

The following `ResourceMaker` constructor method is just `val` now.
```scala
effectie.resource.ResourceMaker.usingResourceMaker
```


* Rename `withResource` in `Ce2ResourceMaker` and `Ce3ResourceMaker` to `maker` (#530)


* Move `ResourceMaker` and `ReleasableResource` to `effectie-cats` (#546)

Having `ReleasableResource` in `effectie-cats` is required to have `Functor` and `Monad` type-classes.

2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ThisBuild / version := "2.0.0-SNAPSHOT"
ThisBuild / version := "2.0.0-beta10"

0 comments on commit a3e18da

Please sign in to comment.