Serialization of Free Monads/Applicatives ?
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 5.5k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 5
Description
Nearly two years ago I asked on the Spotted Leopards repository (which was preparing cats for Scala 3) if it would be possible to enable serialization of Free Monads and got some very interesting answers. Perhaps some things have changed since then, so I thought I'd ask again.
Use Case: Essentially about 7-8 years ago I used wrote a predecessor to Tim Berners-Lee's Solid Platform using Free Monads as a way of building LDP Command scripts such as this one or also
val nameEnum = for {
wacLdr <- web(henryFoafWac)
auth <- web.<~(LinkedDataResource(wacLdr.location,PointedGraph(henryFoaf,wacLdr.resource.graph)),wac.accessTo)()
agentClass <- web.~>(auth,wac.agentClass)()
member <- web.~>(agentClass,foaf.member)()
name <- web.~>(member,foaf.name)()
}
Each of the scripts contained a URL that could be used by the Akka actor system to direct it to the right resource for execution via a RoutingActor. When the right actor received that it would then execute the head of the Free Monad script (as here and then forward the rest of the free monad on to the next actor (via a routing actor).
At the time I thought that was very cool. But to get it to work on an Akka cluster -- which I did not need at the time - it would need those Free Monads to be serialized and potentially sent to an actor on another JVM. The idea being to send the code to the data. Apart from needing to extend it to free applicative to have better parallelism, it would also need these Free constructs to be serializable if one wanted this to work in Akka systems spanning JVMs. The answers to my questions on spotted-leopards made me realize that this was not going to be easy, and also potentially quite brittle, as it ties every Akka system to use the same JVM. Also in a way one would want it to perhaps extend beyond one server to the web, but then I think one really needs to look into work on federated queries, which is quite a research project.
On the other hand this is an example of a use of Free Monads that I have not seen discussed elsewhere. Usually FreeMonads have one interpreter, whereas here each Command in a Free Monad gets interpreted by a different interpreter: one can fetch files in the file system, the other on the web, the other on a DB.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Spotted Leopards discussion and the cited LDPCommand.scala, LDRTestSuite.scala, RWWRoutingActor.scala, and LDPCActor.scala examples to understand the proposed cross-JVM execution model. Determine whether serialization for Free Monads and Free Applicatives is a defined Cats change; the issue currently does not specify an implementation boundary or a testable definition of done.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100