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
    But We still need to clean u pthe error handlign. I'll do that with synchronized and we can evaluate lockless later
    jpcooper
    @jpcooper
    @jsuereth Have you ever needed to work with a few hundred resource simultaneously? I've written a function that takes T[ManagedResource[U]] to ManagedResource[T[U]] for T <: Traversable. However, this method relies on foldLeft and flatMap. This leads to StackOverflowError if the input is too long. Do you know of any better way to do this?
    I was considering writing case class ManagedResourceSequence[a](resource: Seq[a]). Do you see any problems with this?
    jpcooper
    @jpcooper
    Well, one problem is that ManagedResource doesn't expose the resource
    jpcooper
    @jpcooper
    I think what we're actually looking for is making ManagedResource Applicative without flatMap
    Josh Suereth
    @jsuereth_twitter
    yeah
    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
    jpcooper
    @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?
    jpcooper
    @jpcooper
    Yes, but how would it be implemented?
    Josh Suereth
    @jsuereth_twitter
    it already is?
    jpcooper
    @jpcooper
    without flatMap?
    I don't see zip in ManagedResource
    I guess I'm looking for and without flatMap
    jpcooper
    @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
    jpcooper
    @jpcooper
    @jsuereth I suppose we would need to allow one ManagedResource to control another ManagedResource's resource
    jpcooper
    @jpcooper
    @jsuereth I'm going to give it a go with continuations
    jpcooper
    @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
    jpcooper
    @jpcooper
    @jsuereth Do you mean they'll be removed in 2.12?
    Josh Suereth
    @jsuereth_twitter
    yeah
    support was dropped in 2.11
    jpcooper
    @jpcooper
    Shame
    Josh Suereth
    @jsuereth_twitter
    agreed
    jpcooper
    @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
    jpcooper
    @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
    jpcooper
    @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?