並び順

ブックマーク数

期間指定

  • から
  • まで

1 - 40 件 / 115件

新着順 人気順

monadの検索結果1 - 40 件 / 115件

  • ソフトウェアエンジニアとしてモナドを完全に理解する / make-perfect-sense-of-monad

    モナドを完全に理解する

      ソフトウェアエンジニアとしてモナドを完全に理解する / make-perfect-sense-of-monad
    • Type level mapを使ったpreload風関連リソースの取り回し。Indexed monad添え

      この記事はHaskell Advent Calendar 202011日目の記事です(遅延)。 大晦日です。いかがお過ごしでしょうか。 Haskellでapi server等を作った際、rdbへの問い合わせでPreload的なことを行う箇所で、Type level mapを使った所、なかなかの使い勝手だったので、共有します。 さらにIndexed Monadを使い、明らかに残念だった箇所を改善します。 preload? 1+N問題を起こさぬよう、事前に関連リソースを問い合わせておくもの。prefetchとかとも。 posts = Post.find(...) # query Post # view for p in posts for t in p.tags # ここで問い合わせるとN回なので、事前に問い合わせていて欲しい render t やること viewが要求するpreloadを定義

        Type level mapを使ったpreload風関連リソースの取り回し。Indexed monad添え
      • Functor, applicative, and monad - TAH's Site

        Functor, applicative, and monad are related concepts that frequently arise in functional programming. These three ideas give a name to common patterns across different operations defined on different data types, so recognizing their occurrences are important. However, these entities are shrouded in mystery, being associated with "category theory," and in particular, monads have been elevated to a

        • Extensible Effects: beyond the Monad Transformers

          This presentation includes these following three things: 1. Monad 2. Monad Transformers 3. Extensible-Effects Main topics are how to use atnos-eff and comparison between mtl and eff.

            Extensible Effects: beyond the Monad Transformers
          • How does the continuation monad work? | Max Hallinan

            I had trouble using the continuation monad until I understood how it works. Here is what I wish I knew from the beginning. The examples are written in PureScript. What is a continuation? A continuation is the next step in a computation. Consider this expression: 3 * (2 / 2) + 1 We start by evaluating the sub-expression 2 / 2. Let’s replace it with a placeholder for the value of that expression. 3

            • Lysxia - The reasonable effectiveness of the continuation monad

              There are common monads associated with common effects: Maybe for failure, [] (list) for nondeterminism, State for state… What about the continuation monad? We shall see why the answer is all of the above, but better. Indeed, many effects can be understood and implemented in a simple and uniform fashion in terms of first-class continuations. Extensions and imports for this Literate Haskell file {-

              • Writer Monadで気軽にMonad則を破る - Haskell-jp

                Tweet 🎅この記事は、Haskell Advent Calendar 2020 25日目の記事です。 🎄Happy Christmas!!🎄 今回は先日(といっても元の質問の投稿からもう何ヶ月も経ってしまいましたが…)StackOverflowに上がったこちら👇の質問に対する回答の、続きっぽい話を書こうと思います。長いし、質問の回答からスコープが大きく外れてしまうので記事にしました。 haskell - モナド則を崩してしまう例が知りたい - スタック・オーバーフロー MonadとMonoidにある重要な繋がりを説明した後、それを応用したWriter MonadがどうMonoidを使ってMonad則を満たしているのか証明します。そして、Writerのそうした性質を用いて簡単にMonad則を破る例を紹介することで、読者のみなさんがMonad則のみならずdo記法やMonadそのもの

                  Writer Monadで気軽にMonad則を破る - Haskell-jp
                • Monad Transformers and Effects with Backpack

                  A good few years ago Edward Yang gifted us an implementation of Backpack - a way for us to essentially abstract modules over other modules, allowing us to write code independently of implementation. A big benefit of doing this is that it opens up new avenues for program optimization. When we provide concrete instantiations of signatures, GHC compiles it as if that were the original code we wrote,

                  • ふみ a.k.a.DJ Monad on Twitter: "「配列のすべての要素が条件を満たすならtrueを返す」関数を定義するとき、空の配列を渡したらfalseを返すかtrueを返すかが、良いプログラマかどうかの一つの境目だ"

                    • はじめての Monad, Monad Transformer, Extensible Effects | Recruit Tech Blog

                      はじめての Monad, Monad Transformer, Extensible Effects Ariizumi Shumpei こんにちは。RECRUIT Job for Student 2021 Summer で、スタディサプリ ENGLISH の開発を行なっていた有泉洵平です。 スタディサプリ ENGLISH のサーバサイドでは Extensible Effects を導入しています。それを扱うにあたり Monad, Monad Transformer, Extensible Effects を学んだため、この記事にまとめます。 また、RECRUIT Job for Student 2021 Summer に興味のある方は、そちらについても記事を書いたため、参考にしてください。 要約 Monad とは、pure と flatMap というメソッドを持ち、Monad 則を満たすも

                        はじめての Monad, Monad Transformer, Extensible Effects | Recruit Tech Blog
                      • Free Monadで言語内DSLをつくろう - 雨粒blog

                        抽象構文木の構築とその評価の分離 インタプリタやコンパイラでは最初に、コードの文字列を構文解析して抽象構文木 (AST) を構築する。その表現形式はDAGやSSAなどに変化して行くことも多いが、基本的にはこれらの中間表現に対して様々な最適化がほどこされる。インタプリタの場合にはこれが評価され実行されるが、コンパイラの場合にはこれがアセンブリの命令に置き換えられ、スケジューリングされ、レジスタが割り当てられ、最終的にはバイナリが生成される。こうした構文解析や構文木の構築と、中間表現の最適化、その評価の分離は、各工程をそれぞれ独立に作成し、必要に応じて取り替えられるという意味で、とても便利だ。 言語内DSLの処理系をそこまで重くするのは本末転倒感があるが、少なくとも構文木を構築しその評価と分離することは、抽象化の手段として適切な場合もあると思う。Haskellでは、言語内DSLのコードとその評

                          Free Monadで言語内DSLをつくろう - 雨粒blog
                        • Monad は継続、Applicative は並列

                          Scala の cats のドキュメント群が Monad に関する説明としてすごくわかりやすかったので、そこで学んだことをまとめておこうと思った。 モナドを理解したい モナドを理解したいというモチベーションをずっと持っている。Wasm 文脈で Rust に入門しそこで Option や Result と出会い、OCaml で Monadic Parser を意味も分からず実装し、そのための勉強で Parsec を知りH 本で Haskell と一緒に勉強したり、同僚に Scala と cats を布教されたりで、長いことモナド周りの技術に触れている。しかし今でもきちんと理解できている自信がない。何が理解できないのだろうか。 H 本で学んだこと H 本は型クラスについて解説したあとに Functor の説明に入る。ここでは文脈を持った値、文脈を維持したまま関数を適用できる関数として fmap

                            Monad は継続、Applicative は並列
                          • Tutorial: What is a probability monad? (Paolo Perrone)

                            Tutorial talk for the Categorical Probability and Statistics workshop 2020: http://perimeterinstitute.ca/personal/tfritz/2019/cps_workshop/ Title: What is a probability monad? Speaker: Paolo Perrone Topics: - Basic intuition for monads - Basic intuition for probability monads (starting at 08:10) - The distribution monad (starting at 13:45) - The Giry monad (starting at 18:25) - Overview of oth

                              Tutorial: What is a probability monad? (Paolo Perrone)
                            • Extending Equational Monadic Reasoning with Monad Transformers

                              There is a recent interest for the verification of monadic programs using proof assistants. This line of research raises the question of the integration of monad transformers, a standard technique to combine monads. In this paper, we extend Monae, a Coq library for monadic equational reasoning, with monad transformers and we explain the benefits of this extension. Our starting point is the existin

                              • ふみ a.k.a.DJ Monad on Twitter: "怪文書 https://t.co/eCcAs1Enu5"

                                怪文書 https://t.co/eCcAs1Enu5

                                  ふみ a.k.a.DJ Monad on Twitter: "怪文書 https://t.co/eCcAs1Enu5"
                                • 【JavaScript】Promise は Either Monad? - Qiita

                                  イントロダクション JavaScript における Promise は失敗か成功のどちらかを表し、どちらの場合も何らかの値を持つことができる。さらにメソッドチェーンによりパイプラインのようなものを作ることができ、失敗すると short-circuit する。この点において Promise は Either monad の async 版のような感じがする。ここでは JavaScript の Promise と Scala の Either の対応関係を示す。 Note: 筆者は関数型プログラミングに詳しくない。 constructor Promise の constructor である Promise.resolve と Promise.reject はそれぞれ Scala の Right と Left に対応している。

                                    【JavaScript】Promise は Either Monad? - Qiita
                                  • Functor, Applicative, Traversable, Monad について

                                    FP in Scala を読みながら Funcor, Applicative, Traversable, Monad あたりの整理をしていきます。 Functor Applicative Traversable Monad 環境: Scala 2.12.7 Scalaz 7.2.27 Cats 1.6.0 1. Functor Scala では Functor は以下のように表現されます。感覚としては型パラメータを 1 つ取り map が定義できるデータ構造には Functor を与えることができるという感じです。

                                    • ふみ a.k.a.DJ Monad on Twitter: "私がMinecraftで作ったもっとも凶悪な建築は、飛行機械とTNT複製機を組み合わせた絨毯爆撃機だ。一度発進すれば止まることはなく、1m進むたびにTNTを一個投下しながら地表を破壊し尽くしていく https://t.co/cRpS7hJPnV"

                                      私がMinecraftで作ったもっとも凶悪な建築は、飛行機械とTNT複製機を組み合わせた絨毯爆撃機だ。一度発進すれば止まることはなく、1m進むたびにTNTを一個投下しながら地表を破壊し尽くしていく https://t.co/cRpS7hJPnV

                                        ふみ a.k.a.DJ Monad on Twitter: "私がMinecraftで作ったもっとも凶悪な建築は、飛行機械とTNT複製機を組み合わせた絨毯爆撃機だ。一度発進すれば止まることはなく、1m進むたびにTNTを一個投下しながら地表を破壊し尽くしていく https://t.co/cRpS7hJPnV"
                                      • Haskell 型クラス覚書(Functor、Applicative、Monad、Semigroup、Monoid、MonadPlus、Alternative) - Qiita

                                        Haskell 型クラス覚書(Functor、Applicative、Monad、Semigroup、Monoid、MonadPlus、Alternative)Haskell Haskell にあらかじめ備えられている型クラスは、それを知らなくても Haskell のプログラムを書き下すことは可能ですが、知っているとコンパクトに、再利用可能で、曖昧さのないようにプログラムを書き下すことができるようになります。実用的なライブラリの中核となるデータ型はほとんどの場合で Monad を含む複数の型クラスを実装しています。そのようなライブラリを使いこなすためには、型クラスの特性を知っておく必要があり、また自身で作成したデータ型に型クラスを実装するに際してもまた、型クラスの特性を知っておく必要があるわけです。 本記事では、Haskell のよく使う以下型クラスの覚書です。 Functor Appli

                                          Haskell 型クラス覚書(Functor、Applicative、Monad、Semigroup、Monoid、MonadPlus、Alternative) - Qiita
                                        • std::execution, Sender/Receiver, and the Continuation Monad

                                          Some thoughts on the std::execution proposal and my understanding of the underlying theory. What’s proposed From the paper’s Introduction This paper proposes a self-contained design for a Standard C++ framework for managing asynchronous execution on generic execution contexts. It is based on the ideas in [P0443R14] and its companion papers. Which doesn’t tell you much. It proposes a framework wher

                                            std::execution, Sender/Receiver, and the Continuation Monad
                                          • graded monad in nLab

                                            category theory+algebra internalization and categorical algebra monoid object group object ring object algebra object (associative, Lie, …) module object/action object internal locale internal category (→\to more) internal groupoid internal site internal diagram universal algebra algebras over\, algebraic theories algebras over\, monads algebras over\, operads categorical semantics internal logic,

                                            • Making Logic Monad

                                              Programming in Scala - Lecture FourAngelo Corsaro779 views•32 slides

                                                Making Logic Monad
                                              • What is a monad morphism (in Haskell)?

                                                This post briefly explains what a monad morphism is in the context of Haskell, since I wanted a succinct explanation that I could refer to for other posts. In order to keep things short, I will assume that you are already comfortable with Haskell’s Monad class and do notation. A monad morphism is: … a natural transformation … that obeys two laws … so first I’ll explain what a natural transformatio

                                                • ふみ a.k.a.DJ Monad on Twitter: "カラスが目の前に現れ、水飲み場とこちらを交互に見つめていた。水が飲みたいのだと察して栓をひねってあげたら喜ばれた https://t.co/O9UGuL9apo"

                                                  カラスが目の前に現れ、水飲み場とこちらを交互に見つめていた。水が飲みたいのだと察して栓をひねってあげたら喜ばれた https://t.co/O9UGuL9apo

                                                    ふみ a.k.a.DJ Monad on Twitter: "カラスが目の前に現れ、水飲み場とこちらを交互に見つめていた。水が飲みたいのだと察して栓をひねってあげたら喜ばれた https://t.co/O9UGuL9apo"
                                                  • This is not a Monad Tutorial

                                                    John Azariah's Blog Ruminations of a partially-applied functional programmer... Follow me on GitHub This blog post is dedicated to Mitch Denny and Avi Pilosof: my brilliant colleagues who inspired me to talk about this topic, and steered the discussions we had with insightful and thought provoking questions as I tried to refine the explanations. 1. Introduction 2. Let’s get go-ing 3. Improving the

                                                    • Game rules with a Free Monad DSL

                                                      This post is about how and why my multiplayer card game GALGA uses a Free Monad DSL for its game rules. If that’s gobbledygook to you, read on and hopefully it’ll make at least a little more sense by the end! GALGA is like Magic: The Gathering in that each card has its own special rules that change the game. These rules can be simple, like “heal 10 life”, or more complex, like “make healing deal d

                                                        Game rules with a Free Monad DSL
                                                      • 矢印のパターンで理解する Functor〜Applicative〜Monad - Qiita

                                                        F[A]→F[B] に至る矢印を比べて、いろいろな型クラスをまとめて理解する、Cats 入門者向け記事。 はじめに この記事では、Cats の型クラスをテーマにする。 Cats は関数型な Scala プログラミング1のためのライブラリなので、この記事でも関数を扱う。関数型パラダイムで関数2というと数学の関数とだいたい同じだから、定義域の集合から値域の集合へのマッピングのことになる。ただし、数学では写像や射などと言うが、記号でも矢印(→)だし、図の上でも矢印なので、この記事では矢印ということにする。 また扱う型クラスとしては、Functor、Applicative、Monad の周辺をメインとする。前半ではそれらの Scala トレイトが要求する実装必須メソッドのうち、F[A]→F[B] に向かう矢印に還元できるもの3に着目して整理し、さらに後半では、それらの周辺に見られるもう一つのパター

                                                          矢印のパターンで理解する Functor〜Applicative〜Monad - Qiita
                                                        • コンテキストでの型の操作 リストモナドとリスト内包 リストモナドを使ってリストを生成する guard関数 Control.Monadモジュール - 計算機科学のブログ

                                                          入門Haskellプログラミング (Will Kurt(著)、株式会社クイープ(監修、翻訳)、翔泳社)のUNIT5(コンテキストでの型の操作)、LESSON 32(リストモナドとリスト内包)、32.1(リストモナドを使ってリストを生成する)、guard関数、クイックチェック 32-2の解答を求めてみる。 コード lesson/app/Main.hs module Main (main) where import Lib (myFilter) main :: IO () main = do mapM_ (\f -> print $ myFilter f ([1 .. 10] :: [Int])) [even, odd]

                                                          • Javascript 関数プログラミング【Haskell の State Monad を真似てみた】 - Qiita

                                                            最近 Javascript の関数をラムダ式(アロー関数)を使って行う例が、ネット等に多く掲載されています。ラムダ計算は関数型プログラミングの基礎となっているそうです。それならば「ラムダ式を使う事で関数型プログラミングを Javascript でも体験出来るはずだ!」という事でチャレンジしてみました。 以下にソースコードを載せます。 /* * State Monad Emuration program */ const lu = require("./Lists.js" ); // List 操作ライブラリ const ou = require("./Objects.js"); // Object 操作ライブラリ const fst = lst => { return lst[ 0 ] }; // タプルの初項を取得 const snd = lst => { return lst[ 1 ]

                                                              Javascript 関数プログラミング【Haskell の State Monad を真似てみた】 - Qiita
                                                            • コンテキストでの型の操作 Monad型クラス ApplicativeとFunctorの制限 それほど単純ではないecho I/Oアクションを記述する - 計算機科学のブログ

                                                              入門Haskellプログラミング (Will Kurt(著)、株式会社クイープ(監修、翻訳)、翔泳社)のUNIT5(コンテキストでの型の操作)、LESSON30(ApplicativeとFunctorの制限)、それほど単純ではないecho I/Oアクションを記述する、クイックチェック 30-2の解答を求めてみる。 Maybeではパターンマッチにより値を取り出すことができるけど、IOではそれができないから。 コード -- 既に出てきているdo表記を使えばできるけど本章ではdo表記は使わない -- 仮に使えば以下のようにして可能。 altPutStrLn :: IO String -> IO () altPutStrLn s = do x <- s putStrLn x echo :: IO () echo = altPutStrLn getLine main :: IO () main =

                                                              • コンテキストでの型の操作 do表記を使ってMonadを扱いやすくする do表記、リスト - 計算機科学のブログ

                                                                入門Haskellプログラミング (Will Kurt(著)、株式会社クイープ(監修、翻訳)、翔泳社)のUNIT5(コンテキストでの型の操作)、LESSON 31(do表記を使ってMonadを扱いやすくする)、31.4(練習問題)Q31-2の解答を求めてみる。 コード lesson/app/Main.hs module Main (main) where import Lib ( comparePizzas, describePizza, ) sizeData :: [Double] sizeData = [2, 3] costData :: [Double] costData = [9, 10] listMain :: [String] listMain = do size1 <- sizeData cost1 <- costData size2 <- sizeData cost2 <-

                                                                • OCamlでMonadを使う時はppx_letを使おう

                                                                  ちょっとしたCLI(ある程度出来たら記事にします)をOCamlで作っています。その際、初めてppx_letを使ってみたんですが、なかなか良かったので紹介します。 ppx_letは、OCaml界隈では知らない人のいないJane Street社が公開しているPPX拡張です。 OCamlでmonadを扱う時の課題 大抵、resultとかoption(特にresult)をmonadicにつなげていく時、大抵は下のような書き方になります。 let bind v ~f = match v with | Ok v -> f v | Error _ as v -> v let (>>=) v f = bind v ~f let foo = function | v when v > 10 -> Ok v | _ -> Error "error" let bar v = Ok (v * 10) let ()

                                                                  • コンテキストでの型の操作 リストモナドとリスト内包表記 カレンダーの日付、リストのリスト、入れ子、do表記、Monadのメソッド、>>=演算子とラムダ関数、return - 計算機科学のブログ

                                                                    入門Haskellプログラミング (Will Kurt(著)、株式会社クイープ(監修、翻訳)、翔泳社)のUNIT5(コンテキストでの型の操作)、LESSON 32(リストモナドとリスト内包表記)、32.5(練習問題)Q32-2の解答を求めてみる。 コード -- calendar :: [[Int]] -- calendar = [[date | -- date <- [1..last]] | -- last <- [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]] ends :: [Int] ends = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] -- do表記 calendarDo :: [[Int]] calendarDo = do end <- ends return [1..en

                                                                    • コンテキストでの型の操作 Monad型クラス ApplicativeとFunctorの制限 Maybeに対するbind関数の実装 - 計算機科学のブログ

                                                                      入門Haskellプログラミング (Will Kurt(著)、株式会社クイープ(監修、翻訳)、翔泳社)のUNIT5(コンテキストでの型の操作)、LESSON30(ApplicativeとFunctorの制限)、30.5(練習問題)Q30-3の解答を求めてみる。 コード bind :: Maybe a -> (a -> Maybe b) -> Maybe b bind (Just x) f = f x bind Nothing _ = Nothing f :: (Ord a, Num a, Show a) => a -> Maybe String f x = if x < 0 then Nothing else Just $ show $ 2 * x xs :: [Maybe Integer] xs = [Just (-5), Nothing, Just 0, Just 11, Just 1

                                                                      • コンテキストでの型の操作 do表記を使ってMonadを扱いやすくする do表記を使って同じコードを異なるコンテキストで再利用する IOコンテキスト:コマンドラインツールを構築する - 計算機科学のブログ

                                                                        入門Haskellプログラミング (Will Kurt(著)、株式会社クイープ(監修、翻訳)、翔泳社)のUNIT5(コンテキストでの型の操作)、LESSON 31(do表記を使ってMonadを扱いやすくする)、31.2(do表記を使って同じコードを異なるコンテキストで再利用する)、IOコンテキスト:コマンドラインツールを構築する、クイックチェック 31-3の解答を求めてみる。 コード lesson/app/Main.hs module Main (main) where import Lib ( readGrade, ) main :: IO () main = do grade <- readGrade print grade

                                                                        • 【Control.Monad.Trans】(5) IOモナド - Qiita

                                                                          Haskell/Monad transformers A Gentle Introduction to Monad Transformers モナドトランスフォーマー・ステップ・バイ・ステップ 【Control.Monad.Trans】(1) Identityモナド - Qiita 【Control.Monad.Trans】(2) StateTモナド - Qiita 【Control.Monad.Trans】(3) ExceptTモナド - Qiita 【Control.Monad.Trans】(4) ReaderTモナド - Qiita 【Control.Monad.Trans】(5) IOモナド - Qiita Monad transformersを中心に、モナドの基本的な事項をまとめてみました。(1)~(5)までの連載で、Monad transformersを試行していきます。実際に

                                                                            【Control.Monad.Trans】(5) IOモナド - Qiita
                                                                          • コンテキストでの型の操作 do表記を使ってMonadを扱いやすくする do表記を使って同じコードを異なるコンテキストで再利用する IO、コマンドラインツールの構築、Maybe、Just、Nothing - 計算機科学のブログ

                                                                            入門Haskellプログラミング (Will Kurt(著)、株式会社クイープ(監修、翻訳)、翔泳社)のUNIT5(コンテキストでの型の操作)、LESSON 31(do表記を使ってMonadを扱いやすくする)、31.2(do表記を使って同じコードを異なるコンテキストで再利用する)、IO コンテキスト:コマンドラインツールを構築するのクイックチェック 31-3、Maybeコンテキスト:応募者のマップを操作するのクイックチェック 31-4の解答を求めてみる。 コード data Grade = F | D | C | B | A deriving (Eq, Ord, Enum, Show, Read) -- クイックチェック 31-3 readGrade :: IO Grade readGrade = do line <- getLine (return . read) line -- クイック

                                                                            • コンテキストでの型の操作 Monad型クラス return、ラムダ、IO - 計算機科学のブログ

                                                                              入門Haskellプログラミング (Will Kurt(著)、株式会社クイープ(監修、翻訳)、翔泳社)のUNIT5(コンテキストでの型の操作)、LESSON 30(Monad型クラス)、30.3(Monad型クラス)のクイックチェック 30-4の解答を求めてみる。 コード x :: Num a => a -> a x = (+ 2) y :: Num a => a -> IO a y = \n -> return ((+ 2) n) % ghci GHCi, version 8.10.6: https://www.haskell.org/ghc/ :? for help macro 'doc' overwrites builtin command. Use ':def!' to overwrite. (0.00 secs, 0 bytes) (0.00 secs, 0 bytes) Loa

                                                                              • 断然オシャレ!オススメの海外製Wordpressテーマ – Monad Design

                                                                                WordPressでブログを始めるにあたって、たくさんのテーマを検討しました。 最近、国産テーマでもSANGOとかスワローといった、オシャレで使いやすそうなテーマがリリースされていますしね。 検討段階で7つに絞り、最終的に現在使っているSoledadという海外製テーマを選びましたが、わたしが最後まで迷った6つのテーマも未だに捨てがたいので、おすすめテーマとしてまとめてみたいと思います! 2018年版!オシャレな海外製ワードプレステーマ1. PALOMA デモサイト 余計なものが削ぎ落とされた美しいテーマ。特にスマホから見たときの美しさがダントツで、明らかに他との差を感じるデザインです。 フッターのInstagramウィジェットの見せ方も完璧だと思います。 感じのいいオシャレさで万人受けしそうなので、コーポレートサイトを作るなら確実にこのテーマを選びます。 2. TUULIKKI Nordi

                                                                                • コンテキストでの型の操作 do表記を使ってMonadを扱いやすくする do表記を>>=演算子、>>演算子、return、ラムダ関数で書き換える - 計算機科学のブログ

                                                                                  入門Haskellプログラミング (Will Kurt(著)、株式会社クイープ(監修、翻訳)、翔泳社)のUNIT5(コンテキストでの型の操作)、LESSON 31(do表記を使ってMonadを扱いやすくする)、31.4(練習問題)Q31-1の解答を求めてみる。 コード type Pizza = (Double, Double) areaGiveDiameter :: Double -> Double areaGiveDiameter size = pi * (size / 2)^2 costPerInch :: Pizza -> Double costPerInch (size, cost) = cost / areaGiveDiameter size comparePizzas :: Pizza -> Pizza -> Pizza comparePizzas p1 p2 = let co