タグ

haskellに関するkomlowのブックマーク (375)

  • Haskell: The Craft of Functional Programming (PDF)

    I’m happy to announce that the PDF of Haskell, The Craft of Functional Programming (3rd edition) is available to view and download for free. Later in the year I’ll revise it and make it available as an online text. But for now, here it is, uncorrected: https://simonjohnthompson.github.io/craft3e/craft3e.pdf

    Haskell: The Craft of Functional Programming (PDF)
  • The ultimate guide to Haskell Strings · Hasufell's blog

    © 2021. All rights reserved. Site created with Hakyll. Modified theme lanyon-hakyll based on Lanyon. The ultimate guide to Haskell Strings May 7, 2024, Posted by Julian Ospald This guide is aimed at Haskellers who seek to improve their understanding of String types, be it beginners or seasoned developers. It is also meant to be a quick reference/cheat sheet for deciding which string type to use in

  • Functor Typeclass in Haskell

    You might already know the map function: map :: (a -> b) -> [a] -> [b] map _ [] = [] map f (x:xs) = f x : map f xs > map (\x -> x + 1) [1, 2, 3] [2, 3, 4] It takes a function of type a -> b and applies it to each element of a list. The elements change, but the data type storing them ([]) remains the same. In this article, we’ll call such a data type with another type inside it a context. Transform

    Functor Typeclass in Haskell
  • The Haskell Phrasebook

    The Haskell Phrasebook is a free quick-start Haskell guide comprised of a sequence of small annotated programs. It provides a cursory overview of selected Haskell features, jumping-off points for further reading, and recommendations to help get you writing programs as soon as possible.

    The Haskell Phrasebook
  • The <code>&lt;- pure</code> pattern

    Summary: Sometimes <- pure makes a lot of sense, avoiding some common bugs. In Haskell, in a monadic do block, you can use either <- to bind monadic values, or let to bind pure values. You can also use pure or return to wrap a value with the monad, meaning the following are mostly equivalent: let x = myExpression x <- pure myExpression The one place they aren't fully equivalent is when myExpressio

  • Haskell in Production: Riskbook

    To continue our series on Haskell in production, we have an interview with Jezen Thomas, the CTO of Riskbook. Riskbook is a marketplace that connects reinsurance brokers and underwriters, and Haskell has been working out quite well for them. In the interview, we talk about how Haskell can be a blessing when introducing changes to the codebase, what libraries and extensions they use in their projec

    Haskell in Production: Riskbook
  • Haskell For a New Decade

    Haskell Problems For a New Decade It has been a decade since I started writing Haskell, and I look back on all the projects that I cut my teeth on back in the early part of this decade and realise how far the language and tooling have come. Back then Haskell was really barely usable outside of the few people who would “go dark” for months to learn it or those lucky enough to study under researcher

  • Haskell書いてるときになんとなく気をつけていること - LugendrePublic

    信頼性はない 都市伝説かもしれん 大体枕詞に特別な理由がなければがつく 思いついたら徐々に更新する それは違うよってことがあったら @Lugendre まで ghc 8.6.5の話(8.8.1は仕事で使ってなくてな......) コンパイル通るかの確認だけなら最適化オプションO0でコンパイルする stackでいうとstack build --fast 動かすときはO2ビルドしたほうがいいが,インライン展開に5億年消費する なんならこのくらいは静的解析に任せてもいいが,でかいプロジェクトだと一定時間動いてハングアップするのしか世の中にないのでオワリ VSCode のせい説もある ghcideに期待 haskell-language-serverがすべてを解決した CIするときは必ずキャッシュする 毎回一から依存関係やGHCのビルドが走って余裕で1時間超えるようになるので データ構造のフィール

    Haskell書いてるときになんとなく気をつけていること - LugendrePublic
  • STモナドはなぜ変更可能な参照を外へ持ち出せないのか調べてみた - shinharadの日記

    この投稿は、Haskell Advent Calendar 2019 の4日目の記事です。STモナドの仕組みについて書きました。初中級者向けの内容となっています。 はじめに STモナドとは STモナドの型 STモナドの使用例 STモナドで使用されるデータ型と各種関数 Data.STRef newSTRef modifySTRef readSTRef runST 変更可能な参照を外へ持ち出そうとすると エラーメッセージから考察する forallの探求 量化子は型に量的な意味を持たせる 量化子を関数の内側で定義する ランクN多相の概要と特徴 ランクN多相の概要 特徴その1: 型推論の制限を緩和 特徴その2: スコープ内での型の束縛 forallの探求はここで終わり STモナドのトリック newSTRefの結果型の意味 runSTの引数の型の意味 おわりに 訂正内容(2019/12/06) 参考

    STモナドはなぜ変更可能な参照を外へ持ち出せないのか調べてみた - shinharadの日記
  • type family を使って再帰的 ADT をオープンにする

    元ネタは Trees that grow . Haskell では代数的データ型 (ADT) を使ってプログミングに使うデータ構造を定義し,その構造を操作することによりプログラミングを行う. ADT はパターンマッチが容易で,再帰的に定義でき,基的に閉じた構造になっている.そのため便利な反面,その機能が保守で仇となる場合もある.この問題は古くから知られており,いくつかの解決策も提案されてきた.今回はこのうち,現在 GHC で採用されつつある type family を使った解決方法を紹介する. なお,環境として以下を想定している. The Expression Problemプログラミング,特に Haskell を使用したプログラミングにおいて,データ型は非常に重要な役割を持つ.特に,一部のプログラムにおいては,根幹をなすデータ型がいくつか存在するような場合もある.この場合データ型の扱い

    type family を使って再帰的 ADT をオープンにする
  • Parse, don’t validate

    Historically, I’ve struggled to find a concise, simple way to explain what it means to practice type-driven design. Too often, when someone asks me “How did you come up with this approach?” I find I can’t give them a satisfying answer. I know it didn’t just come to me in a vision—I have an iterative design process that doesn’t require plucking the “right” approach out of thin air—yet I haven’t bee

  • Haskellの型と直観論理 - 朝日ネット 技術者ブログ

    開発部のxgotoです。Haskellの初級・中級者向けのトピックを取り上げたいと思います。 今回は型(Type)についてです。型はHaskellの入門書でも必ず最初のほうに説明されるもので、手元のによれば、 型とは、互いに関連する値の集合である。 ---- 『プログラミングHaskell』 Graham Hutton 著 / 山和彦 訳 だとか、 値の世界は型と呼ばれる系統的な集まりへと分割される。 ---- 『関数プログラミング入門 Haskellで学ぶ原理と技法』 Richard Bird 著 / 山下伸夫 訳 などのように書かれています。たとえば Bool は True と False の2つの値からなる集合だし、Intは整数の集合というように、型は値の集合というふうにみることができます。それならば型などと呼ばずに集合と呼べばいいと思いますが、「異なるものには異なる名前をつけろ

    Haskellの型と直観論理 - 朝日ネット 技術者ブログ
  • Beating C with 80 lines of Haskell: wc

    Despite the click-bait title I hope you'll find this post generally illuminating, or at the very least a bit of fun! This article makes no claims that Haskell is "better" than C, nor does it make claims about the respective value of either language, or either implementation. It's simply an exploration into high-performance Haskell, with a few fun tricks and hacks along the way. You can find source

    Beating C with 80 lines of Haskell: wc
  • AST を拡張しよう

    はじめに 実験的な内容です。(@fumievalさん, @matsubara0507さん、アドバイスありがとうございました) モチベーション まずは、以下のような型 Expr と関数 pretty が定義されているとします。 data Expr = Constant Int | Add Expr Expr deriving (Eq, Show) pretty :: Expr -> String pretty (Constant i) = show i pretty (Add e1 e2) = pretty e1 <> " + " <> pretty e2

  • 単純で頑強なメッセージングシステム、franz - モナドとわたしとコモナド

    Haskell製の新しいメッセージングシステムfranz(フランツ)の紹介。 github.com 背景 取引所にあるマシンで取引プログラムを実行するのが我々の仕事だが、朝8時に起動したらあとは昼寝したり酒を飲んだりというわけにはいかない。モニタリングしたり、分析のためにデータを残しておく必要がある。そのため、プログラムによって解析しやすい形でログを出力する。 今までは複数の種類のレコードをシリアライズし、一つのファイルに連結させる独自のフォーマットを10年近く使っていたが、書いていて恥ずかしくなるような多数の問題を抱えていた。 柔軟性が乏しい: 32bit整数や文字列などの単純な値しか格納できず、例えばレコードを含むレコードなどを表現できない。その結果、複雑なデータは一旦文字列に変換するような運用がされており、そのプリティプリンタやパーサは十分にテストされていない。 コードがまとまってい

    単純で頑強なメッセージングシステム、franz - モナドとわたしとコモナド
  • Haskell 解説本 小史 - golden-luckyの日記

    語圏におけるHaskellの解説には、これまで4回の波がありました。 それを思い出しながら、最後に『プログラミングHaskell 第2版』の紹介をします。 第1波 第2波 第3波 第4波 『プログラミングHaskell』が改訂されます 第2版ではプログラミングにおける型の理解が深まると思う ここで買えます 第1波 Haskell解説の1つめの波は、2006年、『入門Haskell』と『ふつうのHaskell』が出版された頃にありました。 このうち、『入門Haskell』は(おそらく)日初のHaskellです。 『入門Haskell』(2006年) 『ふつうのHaskell』(2006年) 『ふつうのHaskell』は、書名だけを見ると「特殊な言語」であるHaskellを「ふつう」に説明しているであるように思えるのですが、実はそうでもなくて、淡々と部品の説明をしていく感じの内容

    Haskell 解説本 小史 - golden-luckyの日記
  • GHC IO モナドの中身

    Haskell の IO モナドって,中身どうなってたんだろと気になってて,ちょっと調べてみた.そのメモ. IO モナドと RealWorld まずは基から. IO モナドは, Haskell の根幹となるモナドで, main も IO で書く. GHC では中身は次のように定義されている [1]: -- In GHC.Types module of ghc-prim package newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #)) 見ての通り, IO a は State# RealWorld -> (# State# RealWorld, a #) の newtype だ.あんまり見慣れない State# RealWorld という型と (# , #) という型が出てきたけど, State# RealWo

    GHC IO モナドの中身
  • Reddit - Dive into anything

  • GHC/RTSのGCについて - Qiita

    Haskellで効率の良いコードを書くためにはいかに不要なサンクを潰すか、ということが重要だと言われています。しかし、そもそもなぜサンクが増えると効率が悪くなるのでしょうか。 Haskellのメモリ確保は高速 まず、Haskellにおいてメモリの確保はどの程度コストがかかるものなのでしょうか。次のプログラムを使って確かめてみましょう。 {-# LANGUAGE BangPatterns #-} {-# OPTIONS_GHC "-ddump-simpl" #-} module Main2 where bench :: Int -> (a -> a) -> a -> a bench n f i = go n i where go 0 !i = i go k !i = go (k-1) (f i) {-# NOINLINE bench #-} main :: IO () main = prin

    GHC/RTSのGCについて - Qiita
  • Why Dependent Haskell is the Future of Software Development

    Hi, I’m Vladislav Zavialov. For the last couple of months, my job at Serokell has been to lead our efforts to improve our primary tool – the Glasgow Haskell Compiler (GHC). I’m focusing on making the type system more powerful, inspired by Richard Eisenberg’s thesis that introduces Dependent Haskell. Dependent types are a feature I’d love to see in Haskell the most. Let’s talk why. There’s a tensio

    Why Dependent Haskell is the Future of Software Development