タグ

monadに関するJxckのブックマーク (38)

  • Option/Either/Future Monads in JS, Python, and More | Toptal

    This monad tutorial gives a brief explanation of monads and shows how to implement the most useful ones in five different programming languages—if you’re looking for monads in JavaScript, monads in Python, monads in Ruby, monads in Swift, and/or monads in Scala, or to compare any implementations, you’re reading the right article! Using these monads you will get rid of a series of bugs like null-po

    Option/Either/Future Monads in JS, Python, and More | Toptal
    Jxck
    Jxck 2018/10/26
  • モナドを理解するために JavaScript で例外モナドを実装してみた - Qiita

    モナドを理解するために Monads for functional programming の例題にある例外モナドを JavaScript で実装してみたのでメモっとく。 戻るボタンをクリックする前に無心で写経してみてほしい。Web ブラウザーの JavaScript コンソールで試せるようにしてあるので! ちなみに、モナドを理解するために書いたコードなので JavaScript でモナドを実用する上では役に立たないのでご注意を。 前提知識 コードを簡潔に表現するために下記のような言語仕様を活用する。 アロー関数 アロー関数を活用して関数を簡潔に表現する。 var add = (n, m) => n + m; // var add = function(n, m) { // return n + m; // }; // var mul = n => m => n * m; // var m

    モナドを理解するために JavaScript で例外モナドを実装してみた - Qiita
    Jxck
    Jxck 2017/12/13
  • Monads to Machine Code

    Monads to Machine Code Just-in-time or JIT compilation is compilation done by dynamically generating executable code. It’s a common technique used in many language runtimes to generate optimized code for hot code paths as well ahead of time compilation for various tasks. So let’s build a small LLVM-like intermediate language and JIT execution engine in Haskell. This will only function with modern

    Jxck
    Jxck 2017/04/24
  • pseudocorta: Monads, promises, arrays in Javascript

    In this article I'll try to explain what is a Monad by developing an intuition based on commonly used patterns and objects, like arrays and promises. Lets start by analyzing a familiar data type: Arrays Arrays Map Lets say we have several useful functions that operate on numbers and return also numbers as their result; for example: var square = function (i) { return i*i }, sum1 = function (i) { re

  • Practical Intro to Monads in JavaScript: Either — Evojam

    My simple and practical Intro to Monads in JS, where I covered basics of Identity and Maybe monads, seemed to be helpful for a lot of folks, so I’ve decide to continue the topic. Now it's time for Either - a tool for fast-failing, synchronous computation chains. A tool that may increase readability and quality of code while reducing error proneness. The best part is that we can still ignore the ca

    Practical Intro to Monads in JavaScript: Either — Evojam
  • bullet-scala: N+1クエリ問題を回避する - 貳佰伍拾陸夜日記

    Scala関西 Summit 2015での発表で触れていたN+1クエリ問題をなんとかするためのライブラリを公開した. 発表は以下のもので, ここでは「関係モナド」という名前で紹介していたけれど, これは口頭でも説明したように便宜上てきとーにつけた名前であって, とくにそういう名前のよく知られたモナドがあるというわけでもなければ, そもそもモナドであるかどうかはあまり質的ではない. この発表のあとに, Rails (Active Record)でのbulletのようにN+1問題の検出をScalaでやる方法はないだろうか, と言っている人がいたので, そういうものを探していて辿りつけるとよかろうということで, bullet-scalaという名前にした. もちろんN+1問題の検出のためのライブラリというわけではないし, 動的に検出するのではなく原理的に問題が発生しないようにするものなので, 思

    bullet-scala: N+1クエリ問題を回避する - 貳佰伍拾陸夜日記
    Jxck
    Jxck 2015/08/17
  • モナドって結局何なのよ? — join to Monad v0.1.3 documentation


    ? Haskell Haskell   Haskell ? Haskell ?:      Haskell 1 Hugs 1Hugs  :type  :info  hugs 
  • JavaScriptのモナド | POSTD

    恒等モナド Maybeモナド リストモナド 継続モナド Do 記法 連鎖呼び出し モナド とは、一連のステップによって実行する計算を記述する際に使用する、1つのデザインパターンです。 純粋関数型プログラミング言語 では、モナドは 副作用を管理する ために広く利用されていますが、 マルチパラダイム言語では、モナドで複雑性を制御することもできます 。 モナドはデータ型をラップして、空の値を自動的に伝播したり( Maybe モナド)、非同期コードを簡略化したり( 継続 モナド)といった、新たな動作を既存のデータ型に追加します。 一連のコードをモナドと見なすためには、その構造には次に挙げる3つの要素が含まれていなければなりません。 型コンストラクタ — 基的な型に対してモナドの動作を追加した型を作成する機能です。例えば、基的なデータ型 number に対して、 Maybe<number> とい

    JavaScriptのモナド | POSTD
  • Promises are the monad of asynchronous programming – The If Works

    In my introduction to monads in JavaScript we saw a couple of monads and examined the commonality between them to expose an underlying design pattern. Before I get on to how that applies to asynchronous programming we need to take one final diversion and discuss polymorphism. Consider the list monad that we implemented before: var compose = function(f, g) { return function(x) { return f(g(x)) }; }

  • Incorporate monads and category theory · Issue #94 · promises-aplus/promises-spec

    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

    Incorporate monads and category theory · Issue #94 · promises-aplus/promises-spec
  • A proof that Promises/A is a Monad

    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

    A proof that Promises/A is a Monad
  • Category Theory for Promises/A+ - BAM Weblog

    Promises are being debated in the JavaScript community. The most popular specification is Promises/A+. It’s a fairly small specification, containing only a single function: then. The function is heavily overloaded which makes it quite complicated - way more than it has to be. I’ll try to show how category theory can give us a much simpler, more generalised and lawful API! A proper Promise/A+ imple

  • 継続モナドによるリソース管理 - Qiita

    継続モナドって何に使うんだ問題に対する一つの例。 リソース管理の問題 プログラミングをやっていると必ずまとわり付いてくるのがリソース管理の問題です。ここで指すリソースというのは、ファイルのハンドルだとか、ソケットだとか、排他処理のためのロックだとか、グラフィックのハンドルだとかそういう話で、GCのない言語だとメモリの管理もこれに含まれるでしょうか。 言うまでもなく、リソースを確保した後はしかるべきタイミングで確実に解放してやる必要があります。しかし往々にして、現実のプログラムではリソースの解放漏れが発生してしまいます。単に解放するコードを書き忘れると言うのが一番単純でしょうもない理由ですが、それでも、C言語のようにリソース解放のための特別な仕組みを持たない言語では、これを徹底するのも結構骨の折れることだったりします。それはともかく、もう少し高尚な悩みとしては、例外との組み合わせで発生する解

    継続モナドによるリソース管理 - Qiita
    Jxck
    Jxck 2015/06/21
  • erlando - ErlangでMaybeモナドとdo記法を使う - Qiita


    ErlangHaskell Maybe do 使RabbitMQ erlando  erlandoListStateMonadPlus guard/2 使cutimport as maybe(A)  Erlang/OTP lists:keyfined/3  false  file
    erlando - ErlangでMaybeモナドとdo記法を使う - Qiita
    Jxck
    Jxck 2015/06/09
    オワコンらしいのでメモっとく > https://twitter.com/voluntas/status/608113605632917504
  • Monads in JavaScript

    Monad is a design pattern used to describe computations as a series of steps. They are extensively used in pure functional programming languages to manage side effects but can also be used in multiparadigm languages to control complexity. Monads wrap types giving them additional behavior like the automatic propagation of empty value (Maybe monad) or simplifying asynchronous code (Continuation mona

    Monads in JavaScript
    Jxck
    Jxck 2015/06/05
    モナドっぽいインタフェースだけじゃなく、 generator 使って do 記法も真似てる。
  • エラー処理の地学史、もしくはあなたがMaybeモナドを使うべき理由。 | 月と燃素と、ひと匙の砂糖


      宿  -1 exception
  • モナドの本当の力を引き出す・・・モナドによる同期/非同期プログラミングの抽象化 - xuwei-k's blog


    2 ScalaFutureEither FutureEither(ApplicativeMonad) 2() (?) ScalaFuture togetter*1/()便便(?) 2Future使
    モナドの本当の力を引き出す・・・モナドによる同期/非同期プログラミングの抽象化 - xuwei-k's blog
    Jxck
    Jxck 2015/03/29
  • ES5の範囲でOption<T>型を表すライブラリ、option-t を作った - saneyuki_s log


     JS, boolean-19999nullundefined RustScalaOption<T>/Maybe  Option<T> 
    ES5の範囲でOption<T>型を表すライブラリ、option-t を作った - saneyuki_s log
  • https://qiita.com/falsandtru/items/4b1a38e15c9b0dadfa6a

  • TypeScriptと関手やモナドなど - 檜山正幸のキマイラ飼育記 (はてなBlog)


    2008CPSJavaScriptCPSJavaScript使JavaScript使JavaScriptJavaScriptAltJSJavaScriptTypeScrit2015JavaScriptTypeScript   TypeScript    TypeScript
    TypeScriptと関手やモナドなど - 檜山正幸のキマイラ飼育記 (はてなBlog)
    Jxck
    Jxck 2015/03/23