query: tag:haskell

 参考にしている書籍にあわせてGHCiのプロンプトを変更するために、ホームディレクトリに下記のように .ghci ファイルを作成しました。

sh>>
$ cat -n .ghci
1 :set prompt "ghci> "
<<--

これでGHCiを起動してみます。

sh>>
$ ghci
GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
*** WARNING: /home/akanuma/.ghci is writable by someone else, IGNORING!
Prelude>
<<--

すると設定ファイル .ghci がオーナー以外のユーザからも書き込み可能になっているということで無視されてしまいました。ファイルのパーミッションを変更して再度起動してみます。

sh>>
$ ls -l .ghci
-rw-rw-r-- 1 akanuma akanuma 21 6月 18 13:27 .ghci
$ chmod 644 .ghci
$ ls -l .ghci
-rw-r--r-- 1 akanuma akanuma 21 6月 18 13:27 .ghci
$ ghci
GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
ghci>
<<--

今度は設定ファイルが読み込まれ、プロンプトがデフォルトの "Prelude>" から "ghci>" に変わりました。

posted by akanuma akanuma on Mon 18 Jun 2012 at 13:32 with 0 comments

Scalaを勉強しなおすために、まずHaskellを勉強してからの方がScalaを理解しやすいという話を聞いたので、Haskellの勉強を始めることにしました。ということでまずはHaskellのコンパイラ、GHC(The Glasgow Haskell Compiler)をインストールしました。yumであっさりインストールできてしまいました。

sh>>

yum install ghc

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

  • base: ftp.iij.ad.jp
  • epel: ftp.tsukuba.wide.ad.jp
  • extras: ftp.iij.ad.jp
  • remi: rpms.famillecollet.com
  • updates: ftp.iij.ad.jp
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package ghc.x86_64 0:6.10.4-3.el5 set to be updated
    --> Processing Dependency: gmp-devel for package: ghc
    --> Processing Dependency: libgmp.so.3()(64bit) for package: ghc
    --> Running transaction check
    ---> Package gmp.x86_64 0:4.1.4-10.el5 set to be updated
    ---> Package gmp-devel.x86_64 0:4.1.4-10.el5 set to be updated
    --> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
Package Arch Version Repository Size

Installing:
ghc x86_64 6.10.4-3.el5 epel 43 M
Installing for dependencies:
gmp x86_64 4.1.4-10.el5 base 201 k
gmp-devel x86_64 4.1.4-10.el5 base 569 k

Transaction Summary

Install 3 Package(s)
Upgrade 0 Package(s)

Total download size: 44 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): gmp-4.1.4-10.el5.x86_64.rpm | 201 kB 00:00
(2/3): gmp-devel-4.1.4-10.el5.x86_64.rpm | 569 kB 00:00
(3/3): ghc-6.10.4-3.el5.x86_64.rpm | 43 MB 00:07

Total 5.5 MB/s | 44 MB 00:08
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : gmp 1/3
Installing : gmp-devel 2/3
Installing : ghc 3/3

Installed:
ghc.x86_64 0:6.10.4-3.el5

Dependency Installed:
gmp.x86_64 0:4.1.4-10.el5 gmp-devel.x86_64 0:4.1.4-10.el5

Complete!
<<--

コマンドが存在することを確認します。

sh>>

which ghci

/usr/bin/ghci

which ghc

/usr/bin/ghc
<<--

バージョンの確認。

sh>>

ghc --version

The Glorious Glasgow Haskell Compilation System, version 6.10.4
<<--

対話モードで起動してみます。

sh>>

ghci

GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Prelude>
Prelude> :q
Leaving GHCi.

<<--

ひとまずコンパイラのインストールは問題なくできたようです。

posted by akanuma akanuma on Mon 18 Jun 2012 at 13:24 with 0 comments

You can get it by installing wl-pprint package.

pre>>

cabal install wl-pprint

<<--

See Also

posted by takiuchi takiuchi on Mon 8 Jun 2009 at 04:09 with 0 comments

Now I am using Haskel and investigating its package system.
I found that I can display the list of packages already installed in the environment by typing the command as follows.

pre>>
ghc-pkg list
<<--

And then I want to prepare cabal-install.
The tool might be found here

I had got it and extracted it. After that, I could build the module by this command.

pre>>
runhaskell Setup.hs configure
<<--

At this point, I got error messages like this:

pre>>
Setup.hs: At least the following dependencies are missing:
Cabal >=1.6&&<1.7,
network >=1&&<3,
HTTP >=4000.0.2&&<4001,
zlib >=0.4&&<0.6
<<--

It means I must get them in advance from the HackageDB.

After I got downloaded them all, I must do just runhaskell repeatedly. It's a simple job.

pre>>
runhaskell Setup.hs configure
runhaskell Setup.hs build
runhaskell Setup.hs install
<<--

If you are a Rubyist, you probably find the similarity between the command above and the usage of setup.rb.
Do you know which is the chicken or the egg? :-)

About 30 minutes went by...

Finally, I got the cabal command.

See Also

posted by takiuchi takiuchi on Mon 8 Jun 2009 at 03:10 with 0 comments