3 ms·
If you're interested in how Category theory and Algebra can inform the design of software, have a look at ZIO Prelude. https://github.com/zio/zio-prelude https
by sideeffffect 6y ago
If you're interested in how Category theory and Algebra can inform the design of software, have a look at ZIO Prelude.
https://github.com/zio/zio-prelude https://github.com/zio/zio-prelude
It's a brand new library for Scala that contains reusable mathematical structures. Still based on algebra and category theory, but it expresses them more or less differently than how they've been expressed in Haskell (and similar languages). For example, unlike Haskell (and Scala's own cats and ScalaZ), it doesn't present the "traditional" Functor -> Applicative -> Monad hierarchy. Instead, it presents the mathematical concepts in a more orthogonal and composable way.
One example out of many, you don't have a Monad. You have two distinct structures:
* Covariant functor, with typical map operation `map[A, B](f: A => B): F[A] => F[B]`
* IdentityFlatten which has a flatten operation `flatten[A](ffa: F[F[A]]): F[A]` and an identity element `any: F[Any]`
When combined together (Scala has intersection types), you get something equivalent to the traditional Monad.
The project is in its infancy, so it may still change significantly, though.
Look here for more detailed explanation:
https://www.slideshare.net/jdegoes/refactoring-functional-type-classes https://www.slideshare.net/jdegoes/refactoring-functional-ty...
https://www.youtube.com/watch?v=OwmHgL9F_9Q https://www.youtube.com/watch?v=OwmHgL9F_9Q
- tsss 6y agoAre there any useful types that have `flatten` but not `map` or `contraMap`?
- sideeffffect 6y agoIf I understood John's motivation from the video, it's that this enables the Flatten structure to be inspectable, because the innards are not hidden behind an opaque closure (A => F[B]), as is the case in regular Monad. Btw, this is a problem that the "Selective applicative functor" too aims to alleviate. You can read more about the inspectability problem (and Selective) at http://eed3si9n.com/selective-functor-in-sbt http://eed3si9n.com/selective-functor-in-sbt The context there is sbt, which is a build tool, but I'm sure the inspectability plays role in many other areas. Note, how he contrasts "Applicative composition" and "Monadic composition".