Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes, you can do that, and you can do something similar in Java or Kotlin by `object : Monoid<Int> { override val mempty = 0; override fun mappend(x: Int, y: Int): Int = x + y }`. This is an encoding of traits as objects though, and is not as nice to work with as e.g. typeclasses and ML modules.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: