Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Rob Norris
@tpolecat
It sounds like you want an effectful unfold.
5 replies
Where you can see local data but can fetch more as you walk the structure.
My Scala World talk does this with a tree structure represented in the database, where it loads data as you walk around. It's a good application of Cofree.
So you might have a look at that.
bblfish
@bblfish:matrix.org
[m]
Ah, interesting that we come into the co-world here :-) Is it this talk Pure Functional Database Programming with Fixpoint Types?
Rob Norris
@tpolecat
yep
bblfish
@bblfish:matrix.org
[m]
You mention the talk by DeGoes at the same conf Streams for (co)Free .
It turns out that just around the time these talks were given was when I started studying coalgebras, coinduction, etc...
Rob Norris
@tpolecat
Oh sorry that was the wrong link. The version I did at Scala World was better.
bblfish
@bblfish:matrix.org
[m]
This one Pure Functional Database Programming‚ without JDBC Scala World, July 11, 2019?
bblfish
@bblfish:matrix.org
[m]
bblfish
@bblfish:matrix.org
[m]
It looks like Matryoshka which you mention in those talks has not moved since 2019 or so. Has it moved elsehwere?
Bob Glamm
@glamm
ok guys, call me crazy, but this should work, right?
def add[F[_]: Monad](ma: F[Int], mb: F[Int]): F[Int] = for { a <- ma; b <- mb } yield a + b
I'm getting value flatMap is not a member of type parameter F[Int], which I think is a sign of .. bad imports, maybe?
yup, I missed cats.implicits._. Darn, disregard
Adam Rosien
@arosien
yep, or cats.syntax.all._ is the newer way
Rob Norris
@tpolecat
@bblfish:matrix.org yeah the new one is called droste
som-snytt
@som-snytt
Is cats-parse pronounced cats-paws or only in New England?
Rob Norris
@tpolecat
cats paahs, it's wicked fast
tpolecat @tpolecat throws beer bottle
bblfish
@bblfish:matrix.org
[m]
cats-paws would be a good name :-)
Swoorup Joshi
@Swoorup
how do i use this http library
bblfish
@bblfish:matrix.org
[m]
working my way carefully through @tpolecat's talks on Fix points.
it is very intriuging because on the Semantic Web we have a notion that looks similar to the IdProf(id: Int, value: ProfF[IdProf]). Well we have PointedGraphs(node,Graph), which allows one to move through a graph, by following links. But there is also a larger concept of NamedGraph(name: URL, g: Graph) where a graph g is found at the URL name, so that works a bit like the id field in a Database.
bblfish
@bblfish:matrix.org
[m]
case class ProfF[A](name: String, year: Int, students: List[A]) is a functor, and the idea is that the Free structures should be recursive ones I think.
There was a very nice blog post by Runar in 2016 A comonad of Graph Decompositions. Sadly it seems to have been his last blog post.
And the Quiver library they were working on has been archived. I wonder if the work there has been followed up anywhere else.
Rob Norris
@tpolecat
Free structures aren’t necessarily recursive. Option is the free pointed set for instance.
bblfish
@bblfish:matrix.org
[m]
Last time I was looking in the direction of Free and CoFree I found this paper Free for DSLs, cofree for interpreters. Does that fit your experience there @tpolecat ?
bblfish
@bblfish:matrix.org
[m]
It does not really look like you were using CoFree as an interpreter in your examples.
Rob Norris
@tpolecat
I haven’t read that paper but Dave Laing knows what he’s taking about.
Alexander Van Hecke
@alexandervanhecke
is there a way to go from F[A => F[B]] to F[A => B] given a Monad[F]?
1 reply
Fabio Labella
@SystemFw
not in that shape, no. What's the larger problem?
Alexander Van Hecke
@alexandervanhecke
I have an F which is a MonadState and I need to implement a function that returns an F[List[Byte] => List[String]]. The returned function should take the bytes, store them in the state and return some value (here a List[String]). I got as far as an F[List[Byte] => F[List[String]]], but need a way to flatten out the second F effect
Fabio Labella
@SystemFw

need to have something that returns an F[List[Byte] => List[String]]

that's the wrong type for your operation

you need List[Byte] => F[List[String]]
the type F[List[Byte] => List[String]] does not let you do the operation that you want
(this is related to the difference between Applicative and Monad btw)
Alexander Van Hecke
@alexandervanhecke
ah excellent suggestion ... let me see if I can make that work. thanks!
Fabio Labella
@SystemFw
let me know if you want to know why that type is incorrect
Alexander Van Hecke
@alexandervanhecke
yes, I'm all ears
Fabio Labella
@SystemFw
so, one of the intuitions for purely functional effects (which is incorrect), is that you have functions that return results and additionally do some effects which appear in the type
instead, you have functions which returns programs, which in turn represent the execution of some effects
e.g def foo(s: String): IO[Int] is not a function that takes a String, returns an Int, and does some IO
it's a function that takes a String and returns an IO[Int] program, which in turn represents the eventual production of an Int + some effects
the other concept is that A => B means that B depends on A
so, in your case, State[Something, List[Byte] => List[String]] represents a program which return a functions List[Byte] => List[String]
but because you want to store the bytes in the state
there has to be a dependency between the thing that can express "input" (list of bytes) and the thing that can express "put in the state", i.e. the F
so you have to have A => F[Something]
if you do F[A => B] there is no way for the state do depend on A (literally the shape does not allow it)