Bob Glamm
07/24/2019, 1:23 PMaddamsson
07/24/2019, 1:23 PMaddamsson
07/24/2019, 1:23 PMaddamsson
07/24/2019, 1:24 PMBob Glamm
07/24/2019, 1:25 PMBob Glamm
07/24/2019, 1:25 PMaddamsson
07/24/2019, 1:28 PMBob Glamm
07/24/2019, 1:28 PMaddamsson
07/24/2019, 1:29 PMaddamsson
07/24/2019, 1:30 PMaddamsson
07/24/2019, 1:30 PMaddamsson
07/24/2019, 1:30 PMaddamsson
07/24/2019, 1:30 PMm -> m -> m
without explaining why this is usefuladdamsson
07/24/2019, 1:30 PMBob Glamm
07/24/2019, 1:49 PMvoid
and Unit
was usefulBob Glamm
07/24/2019, 1:51 PMBob Glamm
07/24/2019, 1:51 PMBob Glamm
07/24/2019, 1:52 PMBob Glamm
07/24/2019, 1:53 PMBob Glamm
07/24/2019, 1:54 PMImran/Malic
07/24/2019, 2:01 PMImran/Malic
07/24/2019, 2:02 PMBob Glamm
07/24/2019, 2:04 PMImran/Malic
07/24/2019, 2:19 PMBob Glamm
07/24/2019, 2:21 PMaddamsson
07/24/2019, 2:37 PMaddamsson
07/24/2019, 2:37 PMaddamsson
07/24/2019, 2:37 PMaddamsson
07/24/2019, 2:38 PMBob Glamm
07/24/2019, 2:44 PMAlpha Ho
07/25/2019, 2:07 PMAlpha Ho
07/25/2019, 2:08 PMBob Glamm
07/25/2019, 2:13 PMBob Glamm
07/25/2019, 2:13 PMBob Glamm
07/25/2019, 2:15 PMAlpha Ho
07/25/2019, 2:19 PMImran/Malic
07/25/2019, 2:20 PMwith a specific behavior
Alpha Ho
07/25/2019, 2:24 PMA -> B
), it also has some constraints on semantics( like it implements Monad/Monoid typeclass)?Imran/Malic
07/25/2019, 2:24 PMmap
in Kotlin over <Something which has a behavior>, we immediately can reason over itās action without looking at the implementation. Because we know the set of behaviors and the action becomes universal, but not in a cat theoretical sense - for those reading.Imran/Malic
07/25/2019, 2:25 PMAlpha Ho
07/25/2019, 2:30 PMList.map
may abstract the behavior of a loop, the parameter of map
is constrained by the from
type and to
type. If I have a List<User>
and I want List<Name>
, then the parameter need to be type (User) -> Name
Alpha Ho
07/25/2019, 2:33 PM(User) -> Name
can be extremely large, thereās only a smaller subspace that may fulfill the semantics of a specific typeclassAlpha Ho
07/25/2019, 2:34 PMAlpha Ho
07/25/2019, 2:38 PMlistOf("b", "a").sortedWith(Comparator { ⦠})
as an example, thereās may be slight difference between sortedWith
takes a function and takes a Comparator. As the latter one comes with a stronger semanticsAlpha Ho
07/25/2019, 2:39 PMAlpha Ho
07/25/2019, 2:39 PMImran/Malic
07/25/2019, 2:40 PMAlpha Ho
07/25/2019, 2:41 PMAlpha Ho
07/25/2019, 2:42 PMmap
function and also obeys the functor lawAlpha Ho
07/25/2019, 2:43 PMImran/Malic
07/25/2019, 2:50 PM* -> *
, please donāt confuse that with HKT.Alpha Ho
07/25/2019, 2:52 PMAlpha Ho
07/25/2019, 2:52 PMImran/Malic
07/25/2019, 2:53 PMmap
does not model loops. Loops are to general, you can do a shit tone of things in them: Sideeffects, break the program and much more. The problem is that with so much possibilities you can not really know what happens in a loop. map
allows us to safely compute over values under the assumption that the return value of f
encapsulates for instance the containerImran/Malic
07/25/2019, 2:54 PMList<A>
and a f: (A) -> B
we know the return is List<B>
and there are no sideeffect or else happing in that functionImran/Malic
07/25/2019, 2:55 PMFunctor#map
as a specific loop, which is pure and only iterates over values in the containerImran/Malic
07/25/2019, 2:56 PMAlpha Ho
07/25/2019, 2:57 PMImran/Malic
07/25/2019, 2:58 PMAlpha Ho
07/25/2019, 2:58 PMImran/Malic
07/25/2019, 2:59 PMImran/Malic
07/25/2019, 2:59 PMAlpha Ho
07/25/2019, 3:00 PMImran/Malic
07/25/2019, 3:02 PMAlpha Ho
07/25/2019, 3:04 PMAlpha Ho
07/25/2019, 3:05 PMImran/Malic
07/25/2019, 3:05 PMAlpha Ho
07/25/2019, 3:08 PMImran/Malic
07/25/2019, 3:08 PMAlpha Ho
07/25/2019, 3:09 PMImran/Malic
07/25/2019, 3:09 PMAlpha Ho
07/25/2019, 3:12 PMAlpha Ho
07/25/2019, 3:12 PMImran/Malic
07/25/2019, 3:15 PMBob Glamm
07/25/2019, 3:15 PM* -> *
is an HKT. (It also happens to be a type constructor)Imran/Malic
07/25/2019, 3:18 PM* -> *
can mean different things depending on the context.Alpha Ho
07/25/2019, 3:18 PMAlpha Ho
07/25/2019, 3:21 PMImran/Malic
07/25/2019, 3:22 PMWhat differentiates FP from OOP is that typeclasses are meant to be implemented outside of their types, instead of by the types.
Thank you too for asking šBob Glamm
07/25/2019, 3:36 PM