6 ms·
A little off-topic, but the author of this paper (Daan Leijen) is also the author of Koka[1], a programming language with algebraic effects. IMO, Koka (or some
by frankpf 9y ago
A little off-topic, but the author of this paper (Daan Leijen) is also the author of Koka[1], a programming language with algebraic effects.
IMO, Koka (or something similar) has more potential to become a mainstream language than "traditional" FP languages (Haskell, OCaml, Idris, etc.).
Effects seem to be easier to understand than monads (at least on a superficial level) and more modular (I don't have a lot of experience with Haskell, so take that with a grain of salt).
Its syntax is also very close to C-like languages.
Taken from the Koka book[2]:
fun square1(x : int) : total int {
return x*x
}
fun square2(x : int) : io int {
println( "a not so secret side-effect" )
return x*x
}
`square1` is a pure mathematical function, so its effect is `total`. `square2` has a side-effect because of `println`, so its effect is `io`. This means that `square2` can raise exceptions, not terminate, be non-deterministic, read and write to the heap, and do any input/output operations.
Note that Koka can infer effects, so these annotations are optional.
[1]: https://www.microsoft.com/en-us/research/project/koka/?from=http%3A%2F%2Fresearch.microsoft.com%2Fen-us%2Fprojects%2Fkoka https://www.microsoft.com/en-us/research/project/koka/?from=...
[2]: https://koka-lang.github.io/koka/doc/kokaspec.html#sec-effect-types https://koka-lang.github.io/koka/doc/kokaspec.html#sec-effec...
- chenglou 9y agoFwiw, OCaml algebraic effects are being implemented: http://kcsrk.info/ocaml/multicore/2015/05/20/effects-multicore/ http://kcsrk.info/ocaml/multicore/2015/05/20/effects-multico... (And then there's https://reasonml.github.io https://reasonml.github.io, which I work on)
- frankpf 9y agoHey there, Reason is a great project! Thanks for working on it! I actually tried to use it very recently in a new project at my workplace, but unfortunately I decided not to. I found some fundamental things were lacking. I didn't find documentation about how to interact with npm libraries (e.g. how do I use a websockets library in Reason? Do I have to create my own bindings? If so, how?). There also seemed to be nothing similar to async/await in Reason/Bucklescript yet and I couldn't find out how to use promises. I'll definitely reevaluate it in the future. I think it is an awesome project with great potential (along with Bucklescript which is awesome too).
- chenglou 9y agoLate reply, but we have such guide here: https://reasonml.github.io/guide/javascript/converting https://reasonml.github.io/guide/javascript/converting You can also check the community's work: https://reasonml.github.io/community/ https://reasonml.github.io/community/
- nwmcsween 9y agoMy dream for a language is a type system that can enforce runtime semantics, preferably at import. import 'mod::memcmp': O(1); where O(1) is big O notation.
- mrkgnao 9y agohttps://en.wikipedia.org/wiki/Hume_(programming_language) https://en.wikipedia.org/wiki/Hume_(programming_language)
- adrianN 9y agoThat would be a very restrictive programming environment, or type checking might fail or produce ridiculously large runtime bounds. It is not decidable whether a given Turing machine has runtime O(n^k) for a particular k, even if you're given the promise that such a k exists.
- tmzt 9y agoCould you make it an attribute of the symbol being exported, part of the contract, and use that to derive an estimated cost of the program? I could see this being used to choose between allocators or schedulers given specific requirements.
- lmm 9y agoI find monads much much more easy to reason about, because they give you a "plain old values" perspective as well as an effectful perspective; most of the time you work like you would with effects, but if you ever get confused you can drop down to seeing what the values are doing. The one mainstream example of something effect-like is Java checked exceptions, which are widely regarded as a failure (and I think for good reason).
- zengid 9y agoCool talk by Leijen about Koka and algebraic-effects: https://youtu.be/hrBq8R_kxI0 https://youtu.be/hrBq8R_kxI0