Giter Site home page Giter Site logo

haskell-exercises's Introduction

すごいHaskell楽しく演習!

「すごいHaskell楽しく学ぼう!」の自作章末演習問題です。
社内勉強会のために作っているものを公開します。

章番号については、オーム社から出ている日本語訳版と対応しています。(Amazon)
原文をオンラインで読むことが出来ますが、こちらは章番号がずれていますのでご注意ください。(英語サイト)

章リンク

ディレクトリ構成

  • Src : 問題を解くためのテンプレートが格納されています。こちらのファイルを直接編集してください。
  • Answer : 解答が格納されています。どうしても解けない場合に参照してください。
  • Test : 自分の解答が正しいかを格納するための自動テストが格納されています。

テスト方法

テストにはQuickCheckを利用しているため、QuickCheckをインストールしてください。cabalコマンドが使える場合には、

$ cabal install QuickCheck

でインストールできます。

章ごとの問題を全てテスト時には、ghciをプロジェクトルートで起動した後、該当のテストファイルを読み込み、testを実行します。
また、特定の関数のみテストする場合には、同様にテストファイルを読み込んだ後、test_(関数名)を実行します。
例えば、第1章のテストを実行する場合は以下のようになります。

> :l Test/Chapter1.hs
> test -- 第1章のテストを全て実行
=== prop_manlen from Test/Chapter1.hs:7 ===
*** Failed! Exception: 'Prelude.undefined' (after 1 test):
((0,0),(0,0))

=== prop_points from Test/Chapter1.hs:10 ===
*** Failed! Exception: 'Prelude.undefined' (after 1 test):
0

=== prop_mancircle from Test/Chapter1.hs:13 ===
*** Failed! Exception: 'Prelude.undefined' (after 1 test):
0

False
> test_manlen -- manlen関数のテストのみ実行
*** Failed! Exception: 'Prelude.undefined' (after 1 test):

なお:l Test/Chapter1.hsを実行した後に:e Src/ChapterX.hsで回答を編集した場合、最新の回答でテストが実行されます。
このため、問題を解く際には以下のようなワークフローをおすすめします。

> :l Test/Chapter1.hs -- 初めにテストファイルを読み込む
Ok, modules loaded: Src.Chapter1, Answer.Chapter1, Main.
> test_manlen -- これから実装する関数のテストが失敗することを確認する
*** Failed! Exception: 'Prelude.undefined' (after 1 test):
((0,0),(0,0))
> :e Src/Chapter1.hs -- 問題を解く
> test_manlen -- 再度テストを実行し、成功するか確認する
+++ OK, passed 100 tests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.