スキップしてメイン コンテンツに移動

Haskell でウェブアプリのサンプルを作ってみる(失敗)

Haskell でウェブアプリのサンプルを作ってみる(失敗)

概要

Haskell で Yesod というものを使ってウェブアプリサンプルを作ってみる
結論からいうと、だめでしたorz

強制改教手続き

神のインストール

まず、Windows で動く Haskell 環境を入手したいと思う。
https://www.haskell.org/platform/windows.html
洗脳され始める
Windows 64bit 版をダウンロードじゃ

あ、
劇物注入開始
ああっ、
だんだん意識が朦朧としてくる
意識混濁
・・・、、、、
Haskell

神を使用する

hell world !
-- Hell Haskell World !!
main = do
 print "Hell Haskell World !"
コンソール
"Hell Haskell World !"

え?ダブルクォーテーション消えないん?
外してみた
-- Hell Haskell World !!
main = do
 print Hell Haskell World !
結果
[1 of 1] Compiling Main             ( h1.hs, h1.o )

h1.hs:4:1:
    parse error (possibly incorrect indentation or mismatched brackets)

あ?
なんじゃこりゃ。なんじゃこりゃ。大事なことなのでもう一度。
なんじゃこりゃ。


さて、落ち着こう。

Yesod の導入

PS R:\> cabal update
Config file path source is default config file.
Config file C:\Users\jskny\AppData\Roaming\cabal\config not found.
Writing default configuration to C:\Users\jskny\AppData\Roaming\cabal\config
Downloading the latest package list from hackage.haskell.org
Note: there is a new version of cabal-install available.
To upgrade, run: cabal install cabal-install
PS R:\> cabal install cabal-install
Resolving dependencies...
Downloading Cabal-1.22.0.0...
Configuring Cabal-1.22.0.0...
Building Cabal-1.22.0.0...
Installed Cabal-1.22.0.0
Downloading cabal-install-1.22.0.0...
Configuring cabal-install-1.22.0.0...
Building cabal-install-1.22.0.0...
Failed to install cabal-install-1.22.0.0
Last 10 lines of the build log ( C:\Users\jskny\AppData\Roaming\cabal\logs\cabal-install-1.22.0.0.log ):
Installing executable(s) in C:\Users\jskny\AppData\Roaming\cabal\bin
C:\bin\MinGW\bin\strip.exe:C:\Users\jskny\AppData\Roaming\cabal\bin\cabal.exe: File format not recognized
cabal.exe: Error: some packages failed to install:
cabal-install-1.22.0.0 failed during the final install step. The exception
was:
ExitFailure 1

ふぁ? 
ふぁあああああああああ、あ゛あ゛あ゛あ゛あ゛あ゛あ゛
とりあえず、yesod だけをインストールしよう
PS R:\> cabal install yesod-platform
Resolving dependencies...
Downloading SHA-1.6.4.1...
Downloading ansi-terminal-0.6.1.1...
Downloading asn1-types-0.2.3...
Configuring ansi-terminal-0.6.1.1...
Downloading auto-update-0.1.0.0...
Configuring asn1-types-0.2.3...
Downloading base16-bytestring-0.1.1.6...
Configuring SHA-1.6.4.1...
Downloading base64-bytestring-1.0.0.1...
Configuring auto-update-0.1.0.0...
Downloading blaze-builder-0.3.3.2...
Downloading byteable-0.1.1...
Downloading byteorder-1.0.4...
Downloading cereal-0.4.0.1...
Building ansi-terminal-0.6.1.1...

..........

Installed authenticate-1.3.2.10
Installed persistent-template-1.3.2.2
Downloading yesod-persistent-1.2.3...
Configuring yesod-persistent-1.2.3...
Installed esqueleto-1.4.4
Building yesod-persistent-1.2.3...
Installed yesod-persistent-1.2.3
Downloading yesod-form-1.3.15.1...
Configuring yesod-form-1.3.15.1...
Building yesod-form-1.3.15.1...
Installed yesod-form-1.3.15.1
Downloading yesod-auth-1.3.4.1...
Configuring yesod-auth-1.3.4.1...
Building yesod-auth-1.3.4.1...
Installed yesod-auth-1.3.4.1
Downloading yesod-auth-hashdb-1.3.0.1...
Configuring yesod-auth-hashdb-1.3.0.1...
Building yesod-auth-hashdb-1.3.0.1...
Installed yesod-auth-hashdb-1.3.0.1
cabal.exe: Error: some packages failed to install:
hjsmin-0.1.4.7 failed during the building phase. The exception was:
ExitFailure 1
hspec-1.11.0 failed during the final install step. The exception was:
ExitFailure 1
wai-app-static-3.0.0 failed during the building phase. The exception was:
ExitFailure 1
yaml-0.8.8.4 failed during the building phase. The exception was:
ExitFailure 1
yesod-1.2.6.1 depends on yaml-0.8.8.4 which failed to install.
yesod-platform-1.2.13.3 depends on wai-app-static-3.0.0 which failed to
install.
yesod-static-1.2.4 depends on wai-app-static-3.0.0 which failed to install.
yesod-test-1.2.3.2 depends on hspec-1.11.0 which failed to install.
PS R:\>

はい。エラーですね。
はいはい。もういいかな。
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\jskny>yesod
'yesod' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。

C:\Users\jskny>

はぁ・・・

このブログの人気の投稿

記述試験の書き方(仮)

記述試験の書き方(仮) 1,まえがき   法学部の試験では記述式の試験が出てくる。   その試験では、あるテーマについて自由に論ぜよとされている。 しかし、論ぜよと言われても、どのように論じればいいのか、すなわち、記述の仕方について教わったことがない(よくよく考えると、法的文章力を習得させる事だけが目的の授業はないと思われる)。   本稿では、私自身が法学畜になり、見聞きし、実際に活用している論述方法についてまとめている、はずである。その要点は、①条文、判例、学説を使う。②単なる事実と法的事実を区別する。③文章内に一貫性を持たせる。である。 法律と、プログラミング

本サイトの今後について

告知 本サイトは今後更新されることは、おそらくありません。 過去記事等はこのまま放置するつもりです。内容の陳腐化並びにその正確性等については保証はできません。自己責任で活用いただければと思います。 This site won't update in future. And Thank's everyone. new site -> sysrigar

node.js で SQLite3 を使用するコードを書くときの予備録

node.js で SQLite3 を使用するコードを書くとき、予備録 まず、非同期処理。 C言語や Perl のように上から下に処理が続くと決して思ってはいけない。 SQLite3 の each は SQL 文実行完了時に呼び出す関数を指定できる SQLite をインストールします、 npm install sqlite3 [test.js] var sqlite3 = require('sqlite3').verbose(); var db = new sqlite3.Database(':memory:'); db.serialize(function() { db.run("CREATE TABLE lorem (info TEXT)"); var stmt = db.prepare("INSERT INTO lorem VALUES (?)"); for (var i = 0; i < 10; i++) { stmt.run("Ipsum " + i); } stmt.finalize(); var listInfo = new Array(); db.each("SELECT rowid AS id, info FROM lorem", function(err, row) { var tmp = new Object(); tmp.id = row.id; tmp.info = row.info; console.log("[ROW]\t" + row.id + ": " + row.info); listInfo.push(tmp); }, function() { // Each 完了時に呼び出される for (var i = 0; i < listInfo.length; i++) { console.log("[BUF]\t" + listInfo[i].id + ": " + listInfo[i].info); } console.lo