Re:Demystifying Differentiable Programming (2018)
by noelwelsh on Monday February 17, 2020 @06:33AM
(#22346951)
Sorry, I don't understand your notation. To me a monad is defined by two functions, pure and bind (aka flatMap). I don't understand how — × M corresponds to this.
Re:Demystifying Differentiable Programming (2018)
by tome on Monday February 17, 2020 @06:52AM
(#22347030)
— × M is the functor. In Haskell it would generally be used as "Writer M", but (M,) can also be used.
Re:Demystifying Differentiable Programming (2018)
by noelwelsh on Monday February 17, 2020 @12:09PM
(#22349016)
Sorry, that doesn't help. I literally do not understand the notation. I do not know what — means in this context, I don't understand what role × plays here, etc.
Re:Demystifying Differentiable Programming (2018)
by tome on Monday February 17, 2020 @12:20PM
(#22349083)
"—" means "the parameter of the type constructor goes here". I believe in Scala you use underscore for this, at the value level at least. "×" is what mathematicians call the type constructor for the usual product type. In Haskell this is called (,). I don't know what it's called in Scala.
So, — × M means something like "type T a = T a M", in Haskell notation.
Re:Demystifying Differentiable Programming (2018)
by edflsafoiewq on Monday February 17, 2020 @12:52PM
(#22349269)
In your notation it would be something like
final case class Mon[A](v: A, m: M) {
def flatMap[B](f: A => Mon[B]): Mon[B] =
Mon(f(this.v).v, f(this.v).m * this.m) // * is M's binary operation
}
object Mon {
def pure(v: A): Mon[A] =
Mon(v, M.unit) // M.unit is M's identity element
}
Shouldn't M actually be a monoid under composition? ie. you should compose like next.k(self.k(d)), not multiply.