タグ

Haskellとtutorialに関するnsyeeのブックマーク (61)

  • mth

    Purely functional, elegant, correct, incremental and composable stream processing that is CPU and memory efficient. This is our (worthy) goal, but where do we start? This problem space is being extensively explored across a variety of languages and libraries, each with subtly different trade-offs and not-so subtly different APIs and terminology. However, these libraries share common goals, and mos

  • Haskellの型クラスを活用する - モナドとわたしとコモナド

    Haskellの型クラスは、うまく使えば高いパフォーマンスと抽象度を両立できる、優れた仕組みである。その使い方のコツは、決して理解の難しいものではない。 小さな性質、大きな恩恵 プログラマは大きなものを小さく見せがちだ。オブジェクト指向プログラミングに慣れている人がやりがちなアンチパターンとして、欲しい機能と、それを分割する基準が現実に寄りすぎていて、一つ一つが巨大というものがある。 普通のプログラミングではありえない例かもしれないが、たとえば家を作りたいことを考える。「ベッド」「箪笥」「台所」「冷蔵庫」「トイレ」「風呂」のように設備ごとに分けた抽象化をしたいと考えるだろう。確かにこれは理に適っているように見える。だが、これらの設備を型クラスでまとめるのは悪手だ。 風呂やトイレには水を利用できるという性質が、冷蔵庫には電気が必要だ。部屋と部屋は壁で仕切られ、場合によっては扉があるかもしれな

    Haskellの型クラスを活用する - モナドとわたしとコモナド
  • 継続モナドによるリソース管理 - Qiita

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

    継続モナドによるリソース管理 - Qiita
  • 関数型なAltJS、PureScriptの入門書を邦訳しました。 - Qiita

    2018/4/30 追記: 古くなっていたこちらの邦訳ですが、プルリクエストを頂き最新版PureScript v0.11に対応しました。当にありがとうございました。 Haskellライクな関数型プログラミング言語PureScriptの入門書、"PureScript By Example"を邦訳しました。書はPureScriptのオリジナルの作者であるPhilさん人が執筆した入門書です。書を理解するにはJavaScriptを知っていることが望ましいですが、そうでなくともすでに何らかのプログラミング言語を知っていれば読みこなすことはできると思います。PureScriptはHaskellを始めとした多くの関数型言語と様々な考え方を共有していますから、PureScriptという言語そのものを学ぶという目的でなくとも、関数型プログラミング全般についての入門としても読むにも適しています。無料で

    関数型なAltJS、PureScriptの入門書を邦訳しました。 - Qiita
  • Primitive Haskell - FP Complete

    I originally wrote this content as a chapter of Mezzo Haskell. I’m going to be starting up a similar effort to Mezzo Haskell in the next few days, and I wanted to get a little more attention on this content to get feedback on style and teaching approach. I’ll be discussing that new initiative on the Commercial Haskell mailing list. The point of this chapter is to help you peel back some of the lay

    Primitive Haskell - FP Complete
  • ScalaプログラマのためのHaskell入門

    4. ●Haskellで手続き的に書くなんて邪道ではないか? ●Haskellの設計者 Simon Peyton Jones の言 ●Tackling the Awkward Squad: monadic input/output, concurrency, exceptions, and foreign-language calls in Haskell ●Haskell is the world’s finest imperative programming language 「Haskellは世界最高の手続き型プログラミング言語です」 ●設計者が手続き型言語と言っているので手続き的に書いて全く問題あ りません Haskellに関するよくある誤解

    ScalaプログラマのためのHaskell入門
  • Minimal Yesod multifile site

  • Haskell アクション 超入門 - Qiita

    Haskellではアクションと呼ばれる機能により副作用が扱えます。アクションの使い方の初歩を説明します。ライブラリで用意されたアクションを手っ取り早く使うことを目的としているため、モナドや圏論には言及しません。 シリーズの記事です。 Haskell 超入門 Haskell 代数的データ型 超入門 Haskell アクション 超入門 ← この記事 Haskell ラムダ 超入門 Haskell アクションとラムダ 超入門 Haskell IOモナド 超入門 Haskell リストモナド 超入門 Haskell Maybeモナド 超入門 Haskell 状態系モナド 超入門 Haskell モナド変換子 超入門 Haskell 例外処理 超入門 Haskell 構文解析 超入門 【予定】Haskell 継続モナド 超入門 【予定】Haskell 型クラス 超入門 【予定】Haskell モナド

    Haskell アクション 超入門 - Qiita
  • Haskell ドリル その1 : georgenano serious side

    一部で話題の Haskell ドリルを公開していきたいと思います。 ただし、georgenanoが加筆・再編集したものなので、会社で使っているものとは異なります。 続きを読む

    Haskell ドリル その1 : georgenano serious side
  • GitHub - sdiehl/llvm-tutorial-standalone: DEPRECATED (Use: https://github.com/llvm-hs/llvm-hs-kaleidoscope )

  • Simple examples - School of Haskell | School of Haskell

    Interactive code snippets not yet available for SoH 2.0, see our Status of of School of Haskell 2.0 blog post Simple applicationmain = putStrLn "Hello, world!"System infoimport System.Info main = do print os print arch print compilerName print compilerVersionSystem environmentimport System.Environment main = do getArgs >>= print getProgName >>= print getEnvironment >>= printSystem environment for

  • Haskellプログラミングのコツのようなもの - Qiita

    こちらを読んだらその2もどうぞ とあるお題 シンプルな問題だけどHaskellプログラミングの基的な考え方を伝えるには良い題材だと思います.解説を試みましょう.お題は3題. テキストデータを読んで40文字以下の行のみ表示せよ. テキストデータを読んで各行の最後の10文字を表示せよ. テキストデータを読んで各行の5番目の文字を表示せよ. お題の分析 お題のプログラムはどれも 標準入力からテキストデータ(を表す文字列)を得る 元のテキストデータをゴニョゴニョして結果をテキストデータにする テキストデータ(を表す文字列)を標準出力に置く というパターンです.ゴニョゴニョの部分の関数をgonyoと名付けましょう.gonyoの具体的な内容はお題ごとに異りますが,型は共通しています.その型シグネチャはgonyo :: String -> Stringです.実は,String -> String型の関

    Haskellプログラミングのコツのようなもの - Qiita
  • モナド教

    前提知識:モナド モナドを理解せずともモナド教を信ずることは出来ますが,理解していればより深く納得できるでしょう. 操作 :: 型 -> 型 は,"型"から"型"へ写す"操作"の存在を表します. モナドの文脈 m が必要とする2つの操作: return :: a -> m a で,値を保ちつつ文脈 m の中に入れ込むことが出来ます. (=<<) :: (a -> m b) -> (m a -> m b) で,「値を文脈に入った別の値へ写す操作」を「文脈に入った値を同じ文脈に入った別の値へ写す操作」に変換します. id :: a -> a は値をそのまま返す操作です. id を =<< で変換して得られる操作 join :: m (m a) -> m a で,二重に文脈に入った値を一重の文脈に入った値に戻すことが出来ます. 文脈の値から生の値を取り出す型 m a -> a を持つ操作は,一般

  • λ Lessons

    λ Lessons Pattern matching, first-class functions, and abstracting over recursion in Haskell This is a short, interactive lesson that teaches core functional programming concepts. It was designed to transform the way you think about performing operations on lists of things, by showing you how functions are executed. You can explore the way map and fold (foldr and foldl) are defined and computed. F

  • http://melpon.org/yesodbookjp/conduit

  • Tutorial - Writing a simple REST API

    Rest for Haskell Write REST APIs in Haskell, generate documentation and client libraries View project onGitHub This tutorial is an introduction to writing REST APIs using the rest packages. It will cover defining the API, running it in a web framework, generating documentation, and generating and running API client libraries. The running example we'll use is an API for a blog. This means our objec

  • Lensで行こう! - Just $ A sandbox

    続編:Lensで行こう!(2):Isoへの拡張 - みょんさんの。 Lensとは Lens(http://hackage.haskell.org/package/lens-3.7.1.2)というパッケージがあります。 非常に大きなパッケージで、中には非常に便利な函数群がたくさん揃っています。 私が調べた限りでは、 "Lens package in Haskell(HaskellのLensパッケージ)" の解説記事はData.Lens(http://hackage.haskell.org/package/lenses-0.1.6)がやたらとヒットするのですが、こちらよりもControl.Lensとその周りのパッケージ群(この段落の最初にリンクが貼ってある方です)の方が色々と便利でたくさんの函数が揃っているので、ぜひConrol.Lensの方を使ってください*1。 さて、Lensって何が出来る

    Lensで行こう! - Just $ A sandbox
  • Conduit Overview - School of Haskell | School of Haskell

    Interactive code snippets not yet available for SoH 2.0, see our Status of of School of Haskell 2.0 blog post Updated locationNote that the most up to date version of this content is available at the conduit repo homepage. You should probably read it there. conduit is a solution to the streaming data problem, allowing for production, transformation, and consumption of streams of data in constant m

  • Conduitの使い方 - Qiita

    使えると便利、Conduitの大雑把な使い方です。 目次 使い始める前に Sourceから全ての値をリストで取得する 複数のSourceの全ての値をリストで取得する 自作Sourceを作成する 出力可能な値の残っているSourceを再利用する Sinkに流れてきた値を全て出力する 自作Sinkを作成する Conduitで流れているデータを加工する 自作Conduitの作成 使い始める前に 使い始める前に、Hackage: conduitから適切な関数を選択する為の最低限の知識として次の事を覚えましょう。 何するものなの? Conduitを構成するベースの型1つ 基の3つの型 2つのオマケの型 何をするものなのか? Conduitはストリームデータを処理する為のライブラリです。 ストリームデータ処理の流れを「データの取得」「データの加工」「最終処理」の3段階に分けて記述していきます。 使用

    Conduitの使い方 - Qiita
  • Applicative Functors | pbrisbin dot com

    Every time I read Learn You a Haskell, I get something new out of it. This most recent time through, I think I’ve finally gained some insight into the Applicative type class. I’ve been writing Haskell for some time and have developed an intuition and explanation for Monad. This is probably because monads are so prevalent in Haskell code that you can’t help but get used to them. I knew that Applica