spebbe / dartz

Functional programming in Dart
MIT License
749 stars 60 forks source link

Task.pure #92

Closed cranst0n closed 2 years ago

cranst0n commented 2 years ago

I may be missing something, but should the Task.pure method be static? Is there a reason it's an instance member?

spebbe commented 2 years ago

Ah, good question! Previously, ApplicativeOps was mixed in rather than just implemented (in Task via MonadCatchOps and MonadOps). pure could then be used for deriving default implementations of map and so on. Now, the pure on Task and other types just look weird :) Should probably be removed, unless you think static versions of them would make sense?

See https://github.com/spebbe/dartz/blob/master/lib/src/applicative.dart#L79 for an example of how it was used.

cranst0n commented 2 years ago

Ah okay. That makes sense. Removing it would be a breaking change so your call, but I think having a method to lift a value into Task makes sense. If you look at PR #93, I added a Task.value which accomplishes the same thing.

spebbe commented 2 years ago

Merged #93 and released in 0.10.1 – Thanks again!