Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add a .bracket operation for Iterant #479
The bracket discussed currently in
def getFile = bracket(openFile)(file => Iterant[Coeval].of(file))(file => Coeval(file.close())) def totallyOk = getFile.mapEval(f => Coeval(f.readFirstLine()))
are possible (and useful).
Maybe something like this would suffice as the implementation of the latter:
Iterant.liftF(fa) .flatMap(a => Iterant.suspend(use(a)).doOnComplete(_ => F.suspend(release(a)))
And maybe it should go under a different name?
@oleg-py hey, I've seen you interested in effects and stuff
Would you mind giving this issue a try?
The discussion at typelevel/cats-effect#113 is probably relevant. What I'm thinking of is that we need to distinguish between normal termination (with error or not) and cancellation, in