For more background information, see:
- The Koka book for a specification of the Koka language and a primer on algebraic effects.
- The library documentation.
- The Koka research page and the slides of a talk presented Lang.Next (April 2012).
- The article Algebraic Effects for Functional Programming[3] about the algebraic effects in Koka.
Pentru ca nici macar nu e suficient de inteligenta sa-si aduca aminte numele site-ului in al carui concurs este prezenta cu mult entuziasm si sloboz in coltul gurii. Iata ca voi indemna cat mai multi „preteni” sa participe la concursurile astea pe bune online, ca rablele obosite sa n-aiba treaba si sa n-aiba sanse de castig la ceva ce nici.
Installing the compiler
At this point there are no binary releases of Koka and you need to buildthe compiler yourself. Fortunately, Koka has few dependencies and buildswithout problems on most common platforms, e.g. Windows, MacOSX, andUnix.
The following programs are required to build Koka:
- The Haskell platform (version 7.4 or later) or Stack.
- The NodeJS runtime (version 4.2 LTS or later).
- Some version of Git for version control.
All these programs are very easy to install on most platforms.Now we can build Koka itself:
- First clone the Koka sources with algebraic effects support:
> git clone https://github.com/koka-lang/koka.git
You can also use the flag-b dev
to get the latest development version. - Go to the newly created Koka directory:
> cd koka
- Install any needed Node libraries using the Node package manager:
> npm install
If you are running on MacOSX or Unix, you may have to run this assudo npm install
so that thenpm
package manager has enoughpermissions to install thejake
andmadoko
tools. - Install
alex
, a lexer generator used by the Koka compiler,a. if you usecabal
,b. or if you usestack
, - Finally, build the compiler and run the Koka interactive environment:
> jake
jake
usesghc
to compile Haskell programs by default.If you usestack
to build the project, set environment variablebuild_with_stack
:only once to build.You can typejake help
to see an overview of all make targets.
The Atom text editor is recommendedto edit Koka programs. You can install support for Koka programs using
> jake atom
(or use
jake sublime
) for the Sublime editor).Running the interactive compiler
![Haye Haye](/uploads/1/2/5/7/125793836/659270954.jpeg)
![Koka Koka](/uploads/1/2/5/7/125793836/312095635.jpg)
After running a plain
jake
command, the Koka interactive environment will start:Now you can test some expressions:
Or load a demo:
And quit the interpreter:
You can also run examples in the browser by setting the host:
Some browser specific demo to try is for example
demo/dom/conway.kk
.Algebraic effect handlers
A novel feature of Koka is a compiled and typed implementation of algebraiceffect handlers (described in detail in [3]).In the interactive environment, you can load various demo files with algebraiceffects which are located in the
test/algeff
directory. This is by defaultincluded in the search path, so we can load them directly usingthe load (:l
) command:Use the
:?
command to get an overview of all commands. Afterloading the scoped
demo, we can run it directly from the interpreter:Some interesting demos are:
common.kk
: Various examples from the paper 'Algebraic Effects forFunctional Programming' [3]. Shows how to implementcommon control-flow abstractions like exceptions, state, iterators,ambiguity, and asynchronous programming.scoped.kk
: Various examples from the paper 'Effect handlers inScope' [5].nim.kk
: Various examples from the paper 'Liberating effects withrows and handlers' [1].async*.kk
: Various asynchronous effect examples.parser.kk
: Implements parser combinators as an effect.
Enjoy,-- Daan
- Daniel Hillerström, and Sam Lindley. “Liberating Effects with Rows and Handlers.” In Proceedings of the 1st International Workshop on Type-Driven Development, 15--27. TyDe 2016. Nara, Japan. 2016. doi:10.1145/2976022.2976033.
- Daan Leijen. “Koka: Programming with Row Polymorphic Effect Types.” In Mathematically Structured Functional Programming 2014. EPTCS. Mar. 2014. arXiv:1406.2061.
- Daan Leijen. Algebraic Effects for Functional Programming. MSR-TR-2016-29. Microsoft Research. Aug. 2016. https://www.microsoft.com/en-us/research/publication/algebraic-effects-for-functional-programming. Extended version of [4].
- Daan Leijen. “Type Directed Compilation of Row-Typed Algebraic Effects.” In Proceedings of Principles of Programming Languages (POPL’17). Paris, France. Jan. 2017.
- Nicolas Wu, Tom Schrijvers, and Ralf Hinze. “Effect Handlers in Scope.” In Proceedings of the 2014 ACM SIGPLAN Symposium on Haskell, 1--12. Haskell ’14. ACM, New York, NY, USA. 2014. doi:10.1145/2633357.2633358
Koka is a function-oriented programming language that seperates pure values from side-effecting computations, where the effect of every function is automatically inferred. Koka has many features that help programmers to easily change their data types and code organization correctly, while having a small language core with a familiar JavaScript like syntax.
The Koka project tries to see if effect inference can be used on larger scale programming. The language is strict (as in ML), but seperates pure values from side effecting computations (as in Haskell). Through the effect types, there is also a strong connection to its denotational semantics, where the effect type of each function has a direct translation to the type signature of the denotational function.
Recently, Koka fully supports user-defined effects through algebraic effect handlers.
Recently, Koka fully supports user-defined effects through algebraic effect handlers.
- Read the “Koka book“; consisting of an introduction and language specification.
- Browse the Library documentation.
- You can try out programming in Koka live at the Koka Tutorial.
- For more technical information, see:
- A technical report about Algebraic Effects in Koka: Algebraic Effects for Functional Programming, Aug 2016
- A paper on the type inference system and semantics of Koka: Koka: Programming with Row Polymorphic Effect Types, Mar 2014
- The slides of a talk presented Lang.Next. Apr 2012.
- Browse the repository at github.com/koka-lang/koka