SyntaxHighlighter

StackEdit CSS

2013年12月7日土曜日

HaskellのWebフレームワークYesodを使ってみる

Haskell Advent Calendar 2013 6日目の記事です

Haskell製のWebフレームワーク、Yesodを使ってみます。

Yesodとは、

Yesod is a Haskell web framework for productive development of type-safe, RESTful, high performance web applications.

らしいです。typesafeやhigh performanceはrubyなどの動的型付け言語とは違うところですね。

cabal install yesod-platform

でインストール出来ます。少し時間がかかるらしいので、待ちましょう。さらに、yesodコマンドを使うために、

cabal install yesod-bin

をしましょう。何故かパスが設定されないので、$HOME/.cabal/binを設定しましょう。

さて、作るものは、最近まどか☆マギカにはまっているのでソウルジェム測定サービスというものにしましょう。

> yesod init
Welcome to the Yesod scaffolder.
I'm going to be creating a skeleton Yesod project for you.

What do you want to call your project? We'll use this for the cabal name.

Project name: SoulgemCounter
Yesod uses Persistent for its (you guessed it) persistence layer.
This tool will build in either SQLite or PostgreSQL or MongoDB support for you.
We recommend starting with SQLite: it has no dependencies.

    s      = sqlite
    p      = postgresql
    pf     = postgresql + Fay (experimental)
    mongo  = mongodb
    mysql  = MySQL
    simple = no database, no auth
    url    = Let me specify URL containing a site (advanced)

So, what'll it be? s
That's it! I'm creating your files now...

---------------------------------------

                     ___
                            {-)   |\
                       [m,].-"-.   /
      [][__][__]         \(/\__/\)/
      [__][__][__][__]~~~~  |  |
      [][__][__][__][__][] /   |
      [__][__][__][__][__]| /| |
      [][__][__][__][__][]| || |  ~~~~
  ejm [__][__][__][__][__]__,__,  \__/


---------------------------------------

The foundation for your web application has been built.


There are a lot of resources to help you use Yesod.
Start with the book: http://www.yesodweb.com/book
Take part in the community: http://yesodweb.com/page/community


Start your project:

   cd SoulgemCounter && cabal sandbox init && cabal install && yesod devel

ブロックを積んでるAAがかわいいw

SoulgemCounterに移動して、yesod develと打てばサーバーが起動します。

enter image description here http://localhost:3000 にアクセスすると、なんか名言っぽいのが切り替わっています。The application is’t built.らしいです。ログには

cabal: At least the following dependencies are missing:
http-conduit ==2.0.*, persistent-sqlite ==1.2.*, wai-extra ==2.0.*

とありました。調べてみると、どうやら入れなおしたほうがいいみたいです。

Yes, Yesod! - みょんさんの。を参考にしつつ環境を入れなおしているうちにどうやらソウルジェムが穢れてきたようです。(てか日付超えちゃっているし

というわけで中途半端な所で終わってしまいました。また余裕ができた時にリトライするかも

リンク

http://www.yesodweb.com/
本家
http://yannesposito.com/Scratch/en/blog/Yesod-tutorial-for-newbies/
マトリックス

0 件のコメント:

コメントを投稿