0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

プログラミング言語Kokaとは

Posted at

プログラミング言語「Koka」

プログラミング言語Kokaとは、Microsoft Research の Daan Leijen 氏らが開発するプログラミング言語で、algebraic effectを扱えることを特徴とします。
まだ開発中の言語ではありますが、動く状態になっており、VSCode拡張やLanguage Server Protocol (LSP) 実装もあり、遊んでみる分には十分そうです。

また、ベンチマーク 結果としても、C++とそれほど遜色なく、他の言語と比べても高速なようです。

ドキュメント に記述されているように、

fun sqr    : (intstd/core/types/int: V) -> total int       // total: mathematical total function    
fun divide : (int,int) -> exn int     // exn: may raise an exception (partial)  
fun turing : (tape) -> div int        // div: may not terminate (diverge)  
fun print  : (string) -> console ()   // console: may write to the console  
fun rand   : () -> ndet int           // ndet: non-deterministic  

関数型に効果(effect)を付加することができ、また、こちらのドキュメントにあるように、関数の呼び出し元で、effect handlerを作ることで、効果を取り扱うことができます。

fun traverse( xs : list<int> ) : yield () 
  match xs 
    Cons(x,xx) -> if yield(x) then traverse(xx) else ()
    Nil        -> ()


fun print-elems() : console () 
  with ctl yield(i)
    println("yielded " ++ i.show)
    resume(i<=2)
  traverse([1,2,3,4])

algebraic effectについて

こちらの記事が参考になりました。

アドベントカレンダー、こんなはずでは。。。

アドベントカレンダー駆動学習をしようと、Koka言語のアドベントカレンダーを作ったのですが、あまり学習が進んでいません。

初日はもっとまともな記事を書こうと思っていたのですが、結局かけないまま、12/2になってしまっています。
さすがにこんなはずではないので、他にも記事を書くつもりではいます。

このように、カレンダー作成者も不勉強な状態なので、「これ見て今からKoka始めました」って方は、カレンダーを埋めるのを手伝っていただければと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?