Join Slack
Powered by
Hi, I am trying to make a Free Monoid of a list us...
# arrow-contributors
a
Ariostonj
04/24/2019, 1:34 AM
Hi, I am trying to make a Free Monoid of a list using Arrows, but I have some doubts. When I read about Free, I always see Initial in the context (maybe my reading is biased) I also read [this](
https://kotlinlang.slack.com/archives/C5UPMM0A0/p1554022508033000
), I assume that for to write a Free Monoid I must create two class a "Mempty" and a "Mappend" and I should provide an Interpreter (is this right ?). But for me, it does not look like [this](
https://github.com/hmemcpy/milewski-ctfp-pdf/blob/master/src/content/2.3/code/scala/snippet02.scala
). Someone can point to me the right direction to do that with using Arrow's (free)[
https://github.com/arrow-kt/arrow/blob/master/modules/free/arrow-free-data/src/main/kotlin/arrow/free/Free.kt
]. Tks for any help and sorry for any trouble;
r
raulraja
04/24/2019, 9:38 AM
A Free monoid can be encoded with just a List of terms and the Monoid for their contained item. This is an example in Scala that could be easily ported to Kotlin
https://github.com/typelevel/spire/blob/master/core/src/main/scala/spire/algebra/free/FreeMonoid.scala
👍 1
raulraja
04/24/2019, 9:39 AM
run
just iterates over the list applying a transformation and combining all internal values with the Monoid of the elements
25
Views
Open in Slack
Previous
Next