Category Theory for Programmers
Kotlin sample code for Bartosz Milewski'sContributing
Contributions (PR, review, issues) are welcome!
If you are interested, please indicate that you are working on in the respective issues. You can find the issues for each chapter here here.. Feel free to claim an issue you want to work on by adding a comment. Someone will then move it to In progress
in the project board
We discuss Arrow and development of FP in general in Kotlin in the Kotlin Community Slack in the arrow and arrow-contributors channels.
Build the project with:
./gradlew runAnk
Spaces and indentation
Please use 2 spaces to indent your code.
Type-check your code
Use ```kotlin:ank:silent``` for code that is compilable, use ```kotlin``` otherwise.
Use a line of .............
to separate between code examples.
functions vs. methods
If it's a "standalone" function, use the function syntax, i.e.
val f: (A) -> B
If it is inside an interface or class, use the method, i.e.
fun f(a: A) : B
Λnk
-
The Docs for Λnk without ank:playground
-
If you define / redefine type classes please define them within a playground environment.
```kotlin:ank:playground
import arrow.core.ForListK
import arrow.core.ListK
import arrow.Kind
import arrow.core.fix
import arrow.typeclasses.Functor
interface ListKFunctor : Functor<ForListK> {
override fun <A, B> Kind<ForListK, A>.map(f: (A) -> B): ListK<B> =
fix().map(f)
}
```...
Playground Docs. But for now a basic set-up as the snippet above is sufficient. Remember that ank:playground wont make the code snippet global for other snippets.
-
In some instances (in the context of coroutine examples) Λnk won't process very long (over ~160 lines) md files. Split them up into < chapter >-Part1.md , < chapter >-Part2.md
-
Debug with (optionally add the --stacktrace)
./gradlew runAnk
🎉
Initial drafts Now there are initial drafts for the missing sections!
It's only necessary to add the translation in Kotlin after the existing snippets in Haskell.
Pick the draft from drafts
directory and move it to src/main/ank
directory to be considered when building the project.
Even the hypothetical file for Scala is included as a help in drafts/scala
so it's possible to add the translation in Kotlin with more information:
Please, note that each snippet has ```kotlin:ank:silent``` by default. Replace it by just ```kotlin``` or ```kotlin:ank:playground``` for different purposes according to this documentation.
License
This work is licensed under a Creative Commons Attribution 4.0 International License.