Bidirectional Typechecking を実装してみた。

はじめに Desk言語ではBidirectional Typechecking のテクニックを使っているという話を聞いてよくわからないので調べてみて最も基本的な単相の双方向型検査器をPrologで書いてみました: % Implementation of Bidirectional Typing Rules: A Tutorial % http…

# 代数的データ型とBNFで妄想するプログラミング言語2

代数的データ型とBNFで妄想するプログラミング言語2 はじめに 昨日はザーッとBNFを書いていく方法を書いてみました。 しかし成果物をみるとちゃんとした仕様書とは言えないものができてしまったように思います。 今日は昨日の成果をもとに仕様のみを抜き出し…

代数的データ型とBNFで妄想するプログラミング言語

代数的データ型とBNFで妄想するプログラミング言語 はじめに BNFってなんだか難しそうって思う方もおられると思いますがそんなに気構えずに楽しく書く気持ちを説明したいと思います。 BNFは狭義の意味ではバッカスナウア記法を用いた構文解析器を表す記法に…

λeffをPrologに移植したら133行で書けた。

代数的効果は継続のようであるけど様々なエフェクトに使えるので今後期待されている技術です。 λeff はそのエッセンスを取り出した言語ですがそれなりに代数的効果を実験できるのでいろいろな言語に実装してみています。 今回はλeff を Prolog に移植してど…

ワークショップの開き方のテンプレートを考えてみた。

いかのような感じでテンプレートを用意してあると便利そうだなぁ。 # 〇〇ワークショップ ## はじめに ワークショップの目的を書きます。 ## 対象者 ここにはワークショップに参加して欲しい人に求められるスキルやあらかじめ環境構築が必要な場合は環境構築…

言語実装を協力して作りたい話

久しくブログを書くことから離れてたのですが、最近は昔と違って言語実装をして遊ぶ人が増えました。 C言語でC言語を作ってブートストラップするような高校生が多くいる状況は一昔前ではなかった状況で楽しいです。 ここまで人が増えてくると、かつてはソロ…

OCamlで作ったgoma言語

この記事はML Advent Calendar 2014 9日目の記事です。 前 SMLでソート 次 Mllexを使ってみる。あるいはlexユーザーに対するmllexの解説 MLアドベントカレンダーが危ない。ということで、今日は、goma言語の紹介をチャラっと書いてみます。 URLはこちら http…

簡単なゲームをOCamlで作ります。

この記事はML Advent Calendar 2014の5日目の記事です。 そういうことで(どういう事だ?)、OCamlでゲームを作ってみました。 ボス的な動きを作り込もうという事で、色々弄ってみてたってだけですけど。 ビルド方法 $ ocamlopt -I `ocamlfind query lablgl` l…

OCamlでオブジェクト指向を使ったゲームのアクター

この記事はML Advent Calendar 2014の3日目の記事です。 昨日は代数データ型を使ってみましたが、今日はオブジェクト指向を使ってみます。 オブジェクト指向自体の説明はもっと良い記事があると思うので、複数のキャラクターを同じリストに入れて動かしたり…

Javaを出力するトランスレータ言語 gomaj

この記事は JVM Advent Calendar 3日目 の記事です。 gomajとは gomajとはOCamlで書いた、Javaを出力するオモチャのトランスレータ言語です。AltJSに対抗するならば、AltJと言えるような言語です。名前は忘れたのですけど(ほんとに忘れたのですいません)、ト…

代数データ型を使ったゲームのアクター

代数データ型を使ったゲームのアクター ご挨拶 こんにちは、すっかり寒くなってインフルエンザにやられてしまったh_sakuraiです。 頭もやられて、ここ1週間ほどまったく進捗ありません。が、そろそろ復活したい所です。 昨日の記事ですが、@camloebaさん曰…

Scala Tutorialsを読む 30 Classes - continued

30 Classes - continued 30 クラスの続き Uniform Access 統一アクセス Scala's getters and setters use the principle of uniform access, e.g. if you change the implementation of a field declared var name to a method def name you will not need t…

Scala Tutorialsを読む 29 Classes

29 Classes クラスの話は長いので、11日だけどあるていど書いてしまいます。30で終わりなのでもう少しです! 29 クラス http://scalatutorials.com/tour/interactive_tour_of_scala_classes.html classes can be defined with minimal amount of code クラ…

Scala Tutorialsを読む 28 Immutable collections with var

http://scalatutorials.com/tour/interactive_tour_of_scala_immutable_collections_with_var.html 28 Immutable collections with var 28 varでのイムータブルコレクション One thing to note is the difference between the +=, +==, -=, -== etc function…

Scala Tutorialsを読む 27 Mutable Collections Operations

27 Mutable Collections Operations ムータブルコレクション演算 http://scalatutorials.com/tour/interactive_tour_of_scala_mutable_collections_operations.html Mutable collections allow to add / remove a single / multple items while modifying th…

Scala Tutorialsを読む 26 Mutable Collections

http://scalatutorials.com/tour/interactive_tour_of_scala_mutable_collections.html 26 Mutable Collections Scala "encourages" using immutable collections (hence they are those used by default) however sometimes mutable collections might have…

Scala Tutorialsを読む 25 Maps

http://scalatutorials.com/tour/interactive_tour_of_scala_maps.html 今日は、Map、写像ですね。 Maps are constructed simply using Map(key1 -> value1, key2 -> value2, ...) Mapは単純にMap(キー1->値1,キー2->値2,...)を使って構築します。 The Map c…

Scala Tutorialsを読む 24 Sets

http://scalatutorials.com/tour/interactive_tour_of_scala_sets.html 24 Sets 集合 Sets are constructed simply using Set(element1, element2, ...) 集合は単純にSet(要素1,要素2,...)を使って構築されます。 The Set can contain mixed types, but the …

Scala Tutorialsを読む 23 Lists

http://scalatutorials.com/tour/interactive_tour_of_scala_lists.html ここを読みます。 List are constructed simply using List(element1, element2, ...) ListはシンプルにList(要素1,要素2,...)を使って作成される List elements can be of any type, …

Scala Tutorialsを読む 22-3

http://scalatutorials.com/tour/interactive_tour_of_scala_arrays.html Since they are using Java's arrays, to print nicely an Array's content, use .mkString(",") Javaの配列を使っているので、配列は.mkString(",")を使ってプリント出来ます。 Arra…

Scala Tutorialsを読む 22-3

http://scalatutorials.com/tour/interactive_tour_of_scala_arrays.html Arrays are mutable (can't change it's size once created, but can modify it's elements) 配列は書き換え可能です(1度作ったらサイズは変更出来ない、しかし要素は変更出来る)

Scala Tutorialsを読む 22-2

http://scalatutorials.com/tour/interactive_tour_of_scala_arrays.html 日付ズレすぎたので、リアルな時間で書いてきます。 Arrays in Scala map to Java primitive Arrays (e.g. Java's int is Scala's Array[Int], Java's String is Array[String] in Sc…

Scala Tutorialsを読む 22 Arrays

http://scalatutorials.com/tour/interactive_tour_of_scala_arrays.html 今日は配列です。 Arrays are constructed simply using Array(element1, element2, ...) 配列はシンプルにArray(要素1,要素2,...)を使って構築されます。

Scala Tutorialsを読む 21 Match as a Switch

http://scalatutorials.com/tour/interactive_tour_of_scala_match_as_a_switch.html 21 Match as a Switch switchとしてのmatchか。as a でとしてって意味があるらしい。 Pattern matching will be familiar to anyone coming from a Haskell background, …

Scala Tutorialsを読む 20 If

http://scalatutorials.com/tour/interactive_tour_of_scala_if.html 20 If Conditions are almost the same as in imperative languages such as Java or C. 条件はほぼ、命令的な言語のJavaやCと同じです。 However one important thing to remember in Sc…

Scala Tutorialsを読む 19 Loops without loops

Scala Tutorialsを読む 19 Loops without loops http://scalatutorials.com/tour/interactive_tour_of_scala_loops_without_loops.html 19 ループのないループ The "Scala" way (or Functional way) of performing a sum of numbers. 数値の合計の計算のScal…

Scala Tutorialsを読む 18 Loops using for

http://scalatutorials.com/tour/interactive_tour_of_scala_loops_using_for.html 今日は18 Loops using forをforを使ったループを読みます。 Scalaのforは、凄く高機能で高級な機能を持っているのですが、その触りで結構普通にループしています。 For loop…

Scala Tutorialsを読む 17 Loops using while

http://scalatutorials.com/tour/interactive_tour_of_scala_loops_using_while.html よし追いついた。今日は17のwhileを使ったループだ。 17 Loops using while Scala doesn't have a "classic" equivalent to the imperative for loop construct that exis…

Scala Tutorialsを読む 16 Assign multiple variables

http://scalatutorials.com/tour/interactive_tour_of_scala_assign_multiple_variables.html 今日は、16 Assign multiple variables 複数の変数の代入かな? Using Tuples, it is possible to assign multiple values to multiple variables (either var or…

Scala Tutorialsを読む 15 Declare multiple variables

今日は15 Declare mltiple variables です。 http://scalatutorials.com/tour/interactive_tour_of_scala_declare_multiple_variables.html 2日遅れてる。どうも、2週間で何かしらの脳内の限界が来るような気がする。半月といったらいいのかな。辛いってい…