並び順

ブックマーク数

期間指定

  • から
  • まで

121 - 160 件 / 191件

新着順 人気順

haskellの検索結果121 - 160 件 / 191件

  • haskellでif文を使いたい

    2つの引数の数字を比較して大きい方をx小さい方をyに入れて返すという関数をhaskellのif文で実装したいと考えています。引数1つのサンプルを参考にして下記を作成したのですが else temp=x x=y y=temp ---------- ^ Failed, no modules loaded. temp=xで上記のようなエラーが出ます. おそらく書き方が間違えていると予想しているのですが、どこが間違えているかわかりません。教えてください。 haskell

      haskellでif文を使いたい
    • 2023年にHaskell関連で知ってよかったこと - あどけない話

      これはHaskell Advent Calendar 2023の19番目の記事です。 フォーマッター 以前、フォーマッターをいくつか試しましたが、どれもイマイチでした。しかし、fourmoluはいけてます。fourmoluは、Ormoluのフォークで、Ormoluが偉大なのでしょう。両方試しましたが、僕はformoluに決めました。 Hackageに上がっているので好きな方法でインストールしてください。 % cabal install fourmolu formoluにHaskellのプログラムを渡すと、整形したプログラムを出力してくれます。ファイルの内容を直接書き換えたいときは、-iオプションを渡します。エディタやIDEと連動できますが、お試しでプロジェクト全体を整形するには、以下のようにするといいでしょう。 % find . -name "*.hs" | xargs fourmolu

        2023年にHaskell関連で知ってよかったこと - あどけない話
      • Writing prettier Haskell with Unicode Syntax and Vim

        A short write-up on combining digraphs, a feature built-in to vim, and Haskell's UnicodeSyntax extension, to easily write beautiful Haskell programs with unicode symbols. #haskell#vim 1 Haskell’s Unicode Syntax Extension Haskell (well, GHC Haskell) features an extension called UnicodeSyntax. When enabled, this extension allows the use of certain unicode symbols in place of their corresponding keyw

        • GitHub - serokell/haskell-with-utf8: Get your IO right on the first try

          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

            GitHub - serokell/haskell-with-utf8: Get your IO right on the first try
          • Compiling a subset of JavaScript to ARM assembly in Haskell - Micah Cantor

            A toy compiler for a subset of JavaScript to ARM assembly, using Haskell. Published: May 29, 2022 I recently got a copy of the book Compiling to Assembly from Scratch by Vladamir Keleshev, which details how to write a compiler for a subset of JavaScript to 32-bit ARM assembly code. The choice to use ARM assembly is mainly for its simplicity in comparison to x86. Keleshev elects to use TypeScript t

              Compiling a subset of JavaScript to ARM assembly in Haskell - Micah Cantor
            • HaskellでもDirectX12したい! - Qiita

              描けた! pic.twitter.com/3h0Jtmlw7U — 🌌S.Percentage🙀 (@Pctg_x8) September 15, 2020 リポジトリはこちら: https://github.com/Pctg-x8/haskell-d3d12-test HaskellのFFI 今回はDirectX12に主軸をおいた記事ではないため、DirectX12の初期化の方法などは解説しません。他の記事をご参照ください。 Haskellも実用的なプログラミング言語の例に漏れず、C言語など他の言語とのインターフェイス(FFI)の仕組みを持っています。 Haskellのそれはかなり「低レベル」かつ「なんでもあり」な感じになっています。 HaskellのFFIの詳細については他の記事を参照してもらうとして、大雑把には以下のような形でインターフェイスが提供されています。 基本データ型 F

                HaskellでもDirectX12したい! - Qiita
              • Parsing With Haskell (Part 1): Lexing With Alex

                This is the first of the two parts of our Parsing with Haskell series. Looking for the second part instead? You can find it here. This two-part tutorial will look into two tools often used together by Haskellers to parse programs: Alex and Happy. We’ll use them to parse a small programming language from scratch. Both Alex and Happy are industrial-strength tools powerful enough to parse even Haskel

                  Parsing With Haskell (Part 1): Lexing With Alex
                • Create a Windows installer for your Haskell project · PatchGirl

                  Create a Windows installer for your Haskell projectIn this blog post, I’ll try to explain how you can create a really simple installer for your Haskell software on Windows and how to deal with external dependencies. IntroductionAlright, let’s get started. We are going to build a simple installer. It will install a desktop shortcut as well as a link shortcut in the start menu. We will be using Stac

                  • 米田の補題、Free theorem と病的な Haskell の関数 - Qiita

                    Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?

                      米田の補題、Free theorem と病的な Haskell の関数 - Qiita
                    • 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
                      • Dynamic Exception Reporting in Haskell

                        Exceptions kind of suck in Haskell. You don’t get a stack trace. They don’t show up in the types of functions. They incorporate a subtyping mechanism that feels more like Java casting than typical Haskell programming. A partial solution to the problem is HasCallStack - that gives us a CallStack which gets attached to error calls. However, it only gets attached to error - so you can either have Str

                        • Haskellで競プロ鉄則本を解いていく

                          Haskellで書籍『競技プログラミングの鉄則』を解いていく本

                            Haskellで競プロ鉄則本を解いていく
                          • CS SYD - JSON Vulnerability in Haskell's Aeson library

                            This blogpost describes a DoS vulnerability in Haskell's aeson package. We have followed appropriate procedure for responsible disclosure but the problem was not fixed, so now we are releasing this to the public in the hope that it may still be fixed afterall. Disclaimer: This story is the result of a team effort at FP Complete in 2018. I have received explicit written permission to post it here.

                            • Announcing Ema - Static Sites in Haskell

                              tldr: Announcing Ema, a new static site generator in Haskell with hot reload destined to develop an unique kind of apps. This post mostly goes over the background of choosing to create it. A little over a year ago I created the rib static site generator in Haskell based on Shake and ghcid. The idea was to be able to write a more intuitive (so no Makefile-like rules) set of instructions for buildin

                              • Study Haskell 2025

                                久しぶりに(10年ぶりに?)Haskell書きたくなったので環境構築していく。 TS がふわふわ言語仕様過ぎて、AIに好きに書かせると崩壊する。コンパイルの難易度が高くても型の表現力が高いHaskellでどこまでやれるかをテストしたい。 (今回 Rust でないのは、システムレベルではない意味論抽象に主にフォーカスしたいから。 具体的には Extensible Effects を使いたい) 初手でこういうプロンプトを書いた。 私は haskell のエキスパートで、ユーザーに haskell の使い方を教えながらコードを書きます。 ユーザーは TypeScript のエキスパートで、多少のRustの知識があります。Haskell は初心者です。 このプロジェクトは最新の cabal でセットアップされています。 stack を使わず、 cabal のみを使ってビルドと依存関係の管理を行いま

                                  Study Haskell 2025
                                • GitHub - augustss/MicroHs: Haskell implemented with combinators

                                  There are two different ways to compile MicroHs: Using GHC. Makefile target bin/gmhs Using the included combinator file and runtime. Makefile target bin/mhs These different ways of compiling need slightly different imports etc. This happens by GHC looking in the ghc/ subdirectory first for any extras/overrides. Compiling MicroHs is really best done using make, but there is also a MicroHs.cabal fil

                                    GitHub - augustss/MicroHs: Haskell implemented with combinators
                                  • Sum and Product Types -�The Fruit Salad & Fruit Snack Example - From F# to Haskell, Scala and Java

                                    Sum and Product Types -�The Fruit Salad & Fruit Snack Example - From F# to Haskell, Scala and Java - The document describes how product types (built using AND) and sum types (built using OR) are used to define types for representing fruit salads and fruit snacks in F#, Haskell, Scala, and Java. - Product types combine elements and are used to define the FruitSalad type, while sum types allow alter

                                      Sum and Product Types -�The Fruit Salad & Fruit Snack Example - From F# to Haskell, Scala and Java
                                    • Making LLVM GEP safer in Haskell

                                      In today's article, I will showcase how Haskell's typesystem can be used to simplify code generation and reduce the chance of bugs involving the LLVM getelementptr instruction. Intro to the GEP instruction LLVM as a compiler framework offers many different low-level instructions, one of which being the getelementptr instruction (commonly abbreviated as just "gep"). With gep, you can compute derive

                                        Making LLVM GEP safer in Haskell
                                      • How Dependent Haskell Can Improve Industry Projects

                                        Dependent types are a hot topic in the Haskell community. Many voices advocate for adding dependent types to Haskell, and a lot of effort is being invested towards that end. At the same time, the sceptics raise various concerns, one being that dependent types are more of a research project than a tool applicable in industrial software development. That is, however, a false dichotomy. While depende

                                          How Dependent Haskell Can Improve Industry Projects
                                        • Haskell の依存型に入門する

                                          Haskell で依存型を扱う方法について勉強したのでメモを残しておきます。 承前 この記事では要素数つきリスト Vect の実装を例に Haskell で依存型を扱うために必要な知識のごく基礎的な部分についてまとめます。ただし、目指すのは Vect を ある程度 開発できる体制を整えることで、十分に開発できる体制は目指しません。というのは、依存型に関わる知識はそれなりに広大で、全てを収めると記事が非常に長くなってしまい、私の精神衛生上良くないことが起こるためです。 この記事では、Haskell での依存型の開発において必要な知識のうち、証明に関するもの以外を一通り揃えることを目指しますが、個人がひっそりと勉強しながら書き進めたもののため、完全な情報となるかは甚だ疑問です。そのため、誤りや欠落等を発見した場合はご指摘いただけると助かります。 なお、この記事が想定する読者は、Haskell

                                            Haskell の依存型に入門する
                                          • 関数型言語とは何か?(Haskellで学ぶ)

                                            「関数型言語とは何か?」について解説します。「オブジェクト指向の複雑さを軽減する」として関数型言語は近年注目を集めています。しかし「関数を中心にプログラムを組み立てる」といっても、具体的なイメージができない方も多いのではないでしょうか。 本書では「強い制約を課して、本来すべきことに集中する」という視点から関数型言語の概要を紹介します。「変数の値を後から変更できない・副作用を禁止する」など、関数型プログラミングならではの特徴を学んでいきましょう。

                                              関数型言語とは何か?(Haskellで学ぶ)
                                            • Haskellのループ処理は flip fix でだいたい書けそう - Qiita

                                              Haskellにはfor文もwhile文もありません。 大抵の場合はmap, filter, foldrのような関数を使えば事足りますし、再帰関数を使えばほとんどのループ処理は書けてしまいます。しかし時には今考えているループを実装するために適切な高階関数が思いつかなかったり、計算結果だけが欲しいのに再帰関数をわざわざ定義するのが煩わしくなったりする状況もあるでしょう。 "グラフからコミュニティ構造を抽出する 〜リッチフローによるグラフの時間発展〜"を書いた時にいくつかループ処理を実装する必要があって、その度に再帰関数を定義するのが大変だったので flip fix を使いました。そして思ったより flip fix の使い勝手が良かったので、この記事ではこれにスポットライトを当てて紹介したいと思います。

                                                Haskellのループ処理は flip fix でだいたい書けそう - Qiita
                                              • Haskell Libraries I Love

                                                2022-05-29 I just wanted to share some of my favorite Haskell libraries, and why I love them. Most of my projects use most of these libraries. relude: Alternative PreludeMore convenient Re-exports common types, type classes, and functions from base, containers, text, bytestring, etc. Types: Text and LText, ByteString and LByteString, etc. Type classes: Alternative, MonadIO, Generic, etc. Functions

                                                  Haskell Libraries I Love
                                                • 計算モデルとプログラミング - Haskell勉強会

                                                  ラムダ計算を分かりやすく説明した本がありました。 「計算モデルとプログラミング」という本です。 計算モデルとプログラミング 作者:猪股 俊光,山田 敬三 発売日: 2019/04/19 メディア: 単行本 本書を参考にして、ラムダ計算の説明方法を学んでみたいと思います。 目次 著者紹介 出版社情報 書評 目次 第1章 計算の世界と計算モデル 1.1 計算の世界 1.2 計算モデル 1.3 計算モデルとプログラミング言語 1.4 アルゴリズムの記法 1.5 数の体系 1.6 自然数上の計算と計算モデル 演習問題 第2章 抽象機械型計算モデル 2.1 機械による計算のモデル化 2.2 順序機械 2.3 有限オートマトン 2.4 チューリング機械 2.5 チューリング機械の計算可能性 2.6 まとめ 演習問題 第3章 命令型計算モデル 3.1 命令による計算のモデル化 3.2 レジスタ機械 3.

                                                    計算モデルとプログラミング - Haskell勉強会
                                                  • VSCodeのHaskell拡張を使って最速開発環境構築 - Qiita

                                                    2020/7/28に新しいHaskell拡張がリリースされました。 https://marketplace.visualstudio.com/items?itemName=haskell.haskell さっそく、こいつを使って最速開発環境構築していくぜ!!! 前提条件 Dockerをインストール VSCodeをインストール Remote - Containers拡張のインストール コンテナ上でHaskell拡張を動作させる 任意のフォルダに.devcontainer.jsonファイルを作成して以下を記載 { "name": "HaskellDevContainer", // DockerhubのHaskell公式イメージ "image": "haskell:8.8", "extensions": [ // HaskellのVSCode拡張をインストール // https://market

                                                      VSCodeのHaskell拡張を使って最速開発環境構築 - Qiita
                                                    • Haskellで正格評価でループを回すには? - hiroki_f’s diary

                                                      Haskellでは再帰的に定義された関数は遅延評価で計算される。 この遅延評価はHaskellの売りの一つであるが、これが時には仇となる。 たとえば、優雅な実装例で知られる次のフィボナッチ数の実装は遅く、メモリの消費量も多い。 fib n = fibs !! n fibs = 1:1:zipWith (+) fib (tail fib) これは、値が評価されるまで計算が待機してメモリが保持されつづけられることが原因だ。 これを解決するには、遅延評価ではなく正格評価で計算すれば良い。 Haskellの神話 - あどけない話 ではzipWithを正格化したzipWith’を定義して、計算を早くする例が提示されていた。 再帰でループを表現するのは、haskellならではの優雅な実装方法だけども、基本は遅延評価なので今あげた問題がついて回る。 例えば、C言語で old=init for (i=1;

                                                        Haskellで正格評価でループを回すには? - hiroki_f’s diary
                                                      • GitHub - matsumonkie/izuna: Show Haskell type annotations when doing code review on Github

                                                        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

                                                          GitHub - matsumonkie/izuna: Show Haskell type annotations when doing code review on Github
                                                        • Haskell入門

                                                          はじめに Haskellは、強い静的型付けを持つ純粋関数型プログラミング言語です。 インストール Haskellの環境は、Haskell PlatformまたはHaskell Stackを使って導入します。 Haskell Platform Haskell Platformをインストールすると、Haskellの処理系(GHC)や周辺ツールを一括で導入することができます。Ubuntuでは、以下のコマンドでHaskell Platformを導入できます。 ただし、この方法で入るHaskell処理系(GHC)はやや古いので、最新のHaskellを使いたい場合は後述するHaskell Stackを導入しましょう。 Haskell Stackのインストール Haskell Stackのインストール手順は次のようになります: apt を使って haskell-stack をインストールする。これによっ

                                                          • 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
                                                            • IDE: Measuring memory usage of Haskell values and patching GHC

                                                              Posted on August 4, 2020 by Michail Pardalos As part of my Google Summer of Code project to add instrumentation to ghcide, I needed to measure the size of Haskell values in memory. After getting blocked by a bug in a GHC primop I fell down a rabbit hole of learning about GHC’s memory layout, C– and making my first contribution to GHC. In this post I want to describe that journey and hopefully enco

                                                              • Haskell Stack プロジェクトを Bazel でビルドしてみる

                                                                仕事では Bazel を使ってビルドすることが多くなり,自分でも Bazel ルールを自作するようになったので,実験も兼ねて趣味の Haskell Stack プロジェクトを Bazel を使ってビルドしてみることにしました. 本記事はそのメモ書きです. あとこれは Haskell Advent Calendar 2020 の2日目の記事です. Bazel Bazel は Google のエンジニアが中心になって開発している OSS のビルドツールだ. 以下のような特徴がある: 必要なコマンドのインストール・バイナリのビルド・コマンドの実行などを記述できる それらは全て専用のサンドボックス内で実行されるため再現性が高い Starlark という Python 風な独自言語で記述する キャッシュなどが工夫されており二度目以降のビルドが高速になりやすい 依存関係を明確に記述する必要がある また

                                                                • Haskellのzip関数を一般化すると何になるか

                                                                  この記事は Haskell Advent Calendar 2023 の7日目の記事です。 zip関数について Haskellには zip 関数というものがあります。この関数は、2つのリストを受け取って、それぞれから取り出した要素を組にしたリストを返します。

                                                                    Haskellのzip関数を一般化すると何になるか
                                                                  • Algebraic Data Types in Haskell

                                                                    Most programming languages have a way to make compound data types. In Haskell, we can do that via algebraic data types. Even though the name might sound scary at first, it’s simply a way to construct types. This article will introduce you to the concept of algebraic data types and show you how to use them. Read further to learn: how to create your own custom Haskell data types; what product and su

                                                                      Algebraic Data Types in Haskell
                                                                    • Why Liquid Haskell matters

                                                                      Since the inception of the Haskell language, the community around it has steadily innovated with language extensions and abstractions. To mention a few, we had the IO monad, all flavors of type classes and constraints, Template Haskell, generalized algebraic data types (GADTs), data kinds, etc. Then we had to deal with the programs resulting from all this innovation, which eventually sprang feelin

                                                                        Why Liquid Haskell matters
                                                                      • So Long Surrogates: How we moved to UTF-8 in Haskell

                                                                        We released a blazingly fast Aho-Corasick implementation, written in Haskell, in 2019. This implementation was based on UTF-16 strings, since Haskell's text library uses that for its internal string representation. However, the most recent major update of text changed its internal string representation from UTF-16 to UTF-8. This is good news for us, since most of our customer’s data is ASCII, this

                                                                        • Calling Haskell from Swift

                                                                          struct User { let name: String let age: Int } // birthday(user: User(name: "Anton", age: 33)) = User(name: "Anton", age: 34) func birthday(user: User) -> User { // Calls Haskell function... } To support this workflow, we need a way to convert the User datatype from Haskell to Swift, and vice versa. We are going to serialize (most) inputs and outputs of a function. Even though the serialization as

                                                                          • Haskell/連想配列のマージとData.Map.Merge.Strict - Qiita

                                                                            HaskellのData.Mapモジュールにおいて定義されるMap型(連想配列)に関して, 2つのMapのマージを定義するData.Map.Merge.Strict.mergeの使い方が意外と大変だったので共有します. Data.Mapについて こちらの記事に基本的な事項がまとめてあります. Data.Mapの使用にはcontainersパッケージのインストールが必要です. こちらでも言及されている通り非正格なData.Mapは特別な理由がない限り非推奨とのことなので, 本記事でも正格版であるData.Map.Strictを用います. keyの型k, valueの型aの連想配列Map k aは配列[(k,a)]からfromList関数によって生成できます:

                                                                              Haskell/連想配列のマージとData.Map.Merge.Strict - Qiita
                                                                            • Tuning Haskell RTS for Kubernetes, Part 1

                                                                              We’re running Haskell in production. We’ve told that story before. We are also running Haskell in production on Kubernetes, but we never talked about that. It was a long journey and it wasn’t all roses, so we’re going to share what we went through. TL;DRConfigure Haskell RTS settings: Match -N⟨x⟩ to your limits.cpuMatch -M⟨size⟩ to your limits.memoryYou can set them between +RTS ... -RTS arguments

                                                                              • Haskell base proposal: unifying vector-like types

                                                                                Haskell base proposal: unifying vector-like types Published March 16, 2021 DISCUSSION I've opened up a Discourse thread to discuss this post. I'll likely respond to comments here and on Twitter, but I'd like to move towards using the more official discussion channels when possible. One of my greatest hopes for the Haskell Foundation is already beginning to be realized: better communication. I'm a

                                                                                  Haskell base proposal: unifying vector-like types
                                                                                • ML Ada Rust C++ Haskell

                                                                                  ML Ada Rust C++ Haskell

                                                                                    ML Ada Rust C++ Haskell