Replies: 1 comment 3 replies
-
https://github.com/koka-lang/koka/blob/dev/test/overload/monoid2.kk There are a few samples in the test folder that show how you can automatically unwrap functions & values in a struct using implicits by prefixing the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
While I appreciate the addition of implicit parameters, I have often found myself having to use copious amounts of them to do useful stuff with them. For example in type-generic arithmetic, where I'll often need to declare the various arithmetic operations, plus some constants for one and zero and the like, plus comparisons, plus bit-shifting operations if I require them. All of these things would often be packaged in a typeclass like "Integral" or "EuclideanRing", for example.
I understand some languages that don't have full typeclass support (and in the case of Koka, if I understand correctly, don't plan on implementing it) mimick typeclasses using structs of functions, and I wondered if these two mechanisms, structs of functions and implicit parameters, fused together, could yield idiomatic code, or perhaps are an antipattern.
Beta Was this translation helpful? Give feedback.
All reactions