Olej писал(а):
Можно, конечно, (и достаточно) всё компилировать вручную, типа:
Код: Выделить всё
bash-4.2$ ghc -o hello_hs hello_hs.hs
[1 of 1] Compiling Main ( hello_hs.hs, hello_hs.o )
Linking hello_hs ...
bash-4.2$ ./hello_hs Вася
Привет от Haskell, Вася
Но Haskell — это целая своеобразная технология, и обидно не использовать все возможности этой технологии, а делать ручную компиляцию...
В этой технологии есть ещё такая штука как cabal (
Common
Architecture for
Building
Applications and
Libraries). Говорят, что это нечто типа make в мире C/C++ (я бы сравнил скорее с Cmake) — построитель проектов Haskell.
Но cabal придётся устанавливать отдельно:
Код: Выделить всё
$ yum list cabal*
Загружены модули: langpacks, refresh-packagekit
Доступные пакеты
cabal-dev.i686 0.9.2-2.fc20 fedora
cabal-install.i686 1.16.0.2-27.fc20 updates
cabal-rpm.i686 0.8.7-1.fc20 updates
$ sudo yum install cabal*
...
Установить 3 пакета (+13 зависимых)
Объем загрузки: 1.7 M
Объем изменений: 9.1 M
...
Выполнено!
Кроме того, что это инструмент построения собственных модульных проектов, это мощнейшее средство управления модулями (библиотеками) Haskell :
Код: Выделить всё
$ cabal --help
...
Commands:
install Installs a list of packages.
update Updates list of known packages
list List packages matching a search string.
info Display detailed information about a particular package.
fetch Downloads packages for later installation.
unpack Unpacks packages for user inspection.
check Check the package for common mistakes
sdist Generate a source distribution file (.tar.gz).
upload Uploads source packages to Hackage
report Upload build reports to a remote server.
init Interactively create a .cabal file.
configure Prepare to build the package.
build Make this package ready for installation.
copy Copy the files into the install locations.
haddock Generate Haddock HTML documentation.
clean Clean up after a build.
hscolour Generate HsColour colourised code, in HTML format.
register Register this package with the compiler.
test Run the test suite, if any (configure with UserHooks).
bench Run the benchmark, if any (configure with UserHooks).
upgrade (command disabled, use install instead)
help Help about commands
...
Код: Выделить всё
$ cabal update
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
С помощью cabal можто найти, выбрать и установить любой модуль (библиотеку) из главного мирового репозитория Haskell (его называют Hackage):
Код: Выделить всё
$ cabal list complex
* complex-generic
Synopsis: complex numbers with non-mandatory RealFloat
Default available version: 0.1.1
Installed versions: [ Not installed ]
Homepage: https://gitorious.org/complex-generic
License: BSD3
* complex-integrate
Synopsis: A simple integration function to integrate a complex-valued
complex functions
Default available version: 1.0.0
Installed versions: [ Not installed ]
Homepage: https://github.com/hijarian/complex-integrate
License: PublicDomain
* complexity
Synopsis: Empirical algorithmic complexity
Default available version: 0.1.3
Installed versions: [ Not installed ]
License: BSD3
* storable-complex
Synopsis: Storable instance for Complex
Default available version: 0.2.1
Installed versions: [ Not installed ]
License: BSD3
Библиотека Haskell очень обширна (1-я команда выведет полный листинг библиотеки):
Код: Выделить всё
$ cabal list >> cabal.lst
$ ls -l cabal.lst
-rw-rw-r--. 1 Olej Olej 1273606 мар 9 11:40 cabal.lst
$ wc -l cabal.lst
41520 cabal.lst
Учитывая, что информация о каждом модуле выводится в 6 строк (см. выше) — это даёт объём библиотеки в 6920 единиц компиляции.