8.7. Monads — OCaml Programming: Correct + Efficient + Beautiful ( >>= ) is a synonym for Lwt.bind , so the library does provide an infix bind operator. Now we start to see some of the great power of the monad design pattern ...
ライブラリの拡充と関数型言語のお勉強を兼ねて、モナドっぽいものを実装して見ました。 単純にモナドをOCamlで使いたいだけならMonad拡張を入れる方が手っ取り早いですが、あまり外部ライブラリへの依存性を入れたくないのと、OCamlの記法の中だけでどこまで出来るか試してみたかったので。 ちなみに誤解を避けるため先に断っておきますが、自分はHaskellerではありません。 以下ではモナドに関してHaskellをかなり参考にしていますが、Haskellのモナドに対する勘違いなどが含まれている可能性があります。 ご了承下さい。 とりあえず、インターフェースとなるシグネチャから作っていきます。 (* 型付きモナドのシグネチャ *) module type TypedMonadType = sig type 'a t val empty : 'a t val singleton : 'a -> '
2010-10-07 ProofCafe/ProofGeneral 2010-09-02 ocaml-nagoya 2010-05-22 ProofCafe/crush 2010-05-21 Fsharp 2010-05-19 ProofCafe 2010-04-25 ProofCafe01 ProofCafe/Coq01 2010-04-22 論文読み会 2010-04-16 ネタ記録庫/OCaml 2010-04-06 ProofCafe/Coq02 2009-12-15 発表資料 2009-12-08 活動記録/20080529 2009-08-10 starterkit 2009-08-01 活動記録/20080331 RecentDeleted OCamlテクニック/daemon 2009-06-05 活動記録/第11回 2009-03-25 活動記録/20080418 活動記録
Let's say I have a list of options: let opts = [Some 1; None; Some 4] I'd like to convert these into an option of list, such that: If the list contains None, the result is None Otherwise, the various ints are collected. It's relatively straightforward to write this for this specific case (using Core and the Monad module): let sequence foo = let open Option in let open Monad_infix in List.fold ~ini
One of my projects for quite a while is to understand Monads. I have been working on this, off and on, for an embarrassing amount of time. Yes, I could have just learned Haskell and that would have done it but I wanted to be a pain in the arse. Also, I had a horrible experience attempting to learn Haskell a long time ago. Thus, I decided as I use Ocaml for most things then I should be able to do i
Syntax extension for Monads in Ocaml Jacques Carette, Lydia E. van Dijk and Oleg Kiselyov Summary This Camlp4 extension provides some syntactic sugar to beautify monadic expressions. Example: A simple but realistic example of the use of a list monad looks like this bind [1; 2; 3] (fun a -> bind [3; 4; 5] (fun b -> return (a + b))) where we assume the appropriate definitions of the functions "bind"
2020/05/03 · Haskellは静的純粋関数型プログラミング言語と言われるジャンルの言語であり、型や状態に厳しくWeb開発に向いていないと思われる方が多いと思います。
この記事は OCaml Advent Calendar の5日目の記事です。 OCamlと連携して、CoqでもIO処理ができるようにするためのライブラリを作った。 http://github.com/yoshihiro503/coqio このライブラリを使えば、例えば次のようなコードを書くことができる。 Require Import Monad IO. Open Scope string_scope. Definition main : IO unit := do _ <- print "Hello" ; println ", world!". Haskell風のdo式みたいな記法が便利だね。print関数には文字列だけでなく、Showクラスのインスタンスとなる型を持つ式ならばなんでも与えることができる*1。 このコードを次のコマンドでExtractすればcoq.mlというOCamlのソー
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く