Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Josh Suereth
    @jsuereth_twitter
    SO
    1. Using flatMap is "ok" I think, if we trampoline
    1. I think having an applicative + traverse would be really nice. What do you need to make that happen?
    I'm thinking of non/cats extension
    Justin Paston-Cooper
    @jpcooper
    The problem right now as that ManagedResource doesn't have an open method like AbstractManagedResource does
    Josh Suereth
    @jsuereth_twitter
    right, so you need to assume things about it.....
    is "zip" enough on managed resource?
    Justin Paston-Cooper
    @jpcooper
    Yes, but how would it be implemented?
    Josh Suereth
    @jsuereth_twitter
    it already is?
    Justin Paston-Cooper
    @jpcooper
    without flatMap?
    I don't see zip in ManagedResource
    I guess I'm looking for and without flatMap
    Justin Paston-Cooper
    @jpcooper
    @jsuereth Doesn't that still involve a big stack, or am I missing something?
    This is what I'm doing:
    def sequenceManagedResources[R, T[X] <: TraversableOnce[X]](managedResources: T[ManagedResource[R]])(implicit canBuildFrom: CanBuildFrom[T[ManagedResource[R]], R, T[R]]): ManagedResource[T[R]] = {
        val initialBuilderResource = unitManaged(canBuildFrom(managedResources))
    
        val finalManagedBuilder = managedResources.foldLeft(initialBuilderResource) { case (builderResource, managedR) ⇒
          builderResource.flatMap { builder ⇒
            managedR.map(r ⇒ builder += r)
          }
        }
    
        finalManagedBuilder.map(_.result())
      }
    def unitManaged[T](value: => T): ManagedResource[T] = {
        managed(()).map(_ ⇒ value)
      }
    Josh Suereth
    @jsuereth
    hey, sorry
    they may both have that issue....
    for popping the stack, we'd need to use an alternative mechanism for this. I have an idea for how to do it, need to experiment
    Justin Paston-Cooper
    @jpcooper
    @jsuereth I suppose we would need to allow one ManagedResource to control another ManagedResource's resource
    Justin Paston-Cooper
    @jpcooper
    @jsuereth I'm going to give it a go with continuations
    Justin Paston-Cooper
    @jpcooper
    Sorry for the mess. I realise the implementation of and in my version of scala-arm uses .reflect. Why was this removed in the latest version?
    Josh Suereth
    @jsuereth_twitter
    because CPS transformed were removed from being supported in scala :(
    I like continuations
    SO, what we should do here
    is basically optimise for the "AbstractMangedResource" case
    Justin Paston-Cooper
    @jpcooper
    @jsuereth Do you mean they'll be removed in 2.12?
    Josh Suereth
    @jsuereth_twitter
    yeah
    support was dropped in 2.11
    Justin Paston-Cooper
    @jpcooper
    Shame
    Josh Suereth
    @jsuereth_twitter
    agreed
    Justin Paston-Cooper
    @jpcooper
    How do you mean that support has been dropped though? Isn't just a separate module which can be depended on?
    Josh Suereth
    @jsuereth_twitter
    which no one is maintaining
    i.e. as language features change, I wouldn't rely on that module
    Justin Paston-Cooper
    @jpcooper
    I understand
    Josh Suereth
    @jsuereth_twitter
    hmmm
    actually, looks like someone picked i tup
    er picked it up
    we removed it from ARM before that happened
    Yang, Bo
    @Atry
    Hi @jsuereth_twitter , could you review my PR #54 , please?
    @jsuereth @jsuereth_twitter , which account are you using?
    Yang, Bo
    @Atry
    Hi @jsuereth_twitter @jsuereth , would you mind changing @Arty to @Atry in https://github.com/jsuereth/scala-arm/releases/tag/v2.0, please
    Justin Paston-Cooper
    @jpcooper
    @jsuereth_twitter You may remember that we talked a while ago about how to sequence lots of ManagedResources without getting a stack overflow on calling .acquireAndGet. We discussed the possibility of continuations. I've been wondering whether it could be done more easily. Have you thought about the problem since at all?
    Oh I see that that conversation is just a few lines up
    Justin Paston-Cooper
    @jpcooper
    I think what we actually want is for ManagedResource to be applicative, so that we can build up our sequence of resources
    Justin Paston-Cooper
    @jpcooper
    Actually disregard what I said. Of course, it already is applicative
    Justin Paston-Cooper
    @jpcooper
    @jsuereth I've made a prototype of ManagedResource which does flatMap while avoiding big stacks of trys for closing resources. Could you tell me what you think? I understand that it's nicer to hide the closing of a resource from other resources, but I can't see any other way to do this other than using continuations. https://gist.github.com/anonymous/32e847129948b84e622e715cecd4ff6b
    Yang, Bo
    @Atry

    Hello, @jsuereth , I wonder if scala-arm can be turn into some kind of monad.

    If it can be modeled as monad, we can use it with ThoughtWorks Each. The syntax will be very close to RAII in C++.

    MachineLearning
    @zhangshengshan
    exception in scala-arm for block will not be catch , while will be thrown , is this true?