728x90
하스켈 설치 및 Hello World 출력해보기
Quick steps to get up and running with Haskell on Ubuntu
하스켈을 설치하고 Hello World 를 출력하는 간단한 예제를 실행해보자.
먼저 가상환경을 만든다.
1 2 3 4 5 6 7 8 | root@gcloudx:~# virtualenv -p python3 venvhaskell Running virtualenv with interpreter /usr/bin/python3 Using base prefix '/usr' New python executable in /root/venvhaskell/bin/python3 Also creating executable in /root/venvhaskell/bin/python Installing setuptools, pip, wheel...done. root@gcloudx:~# | cs |
1 2 3 | root@gcloudx:~# cd venvhaskell root@gcloudx:~/venvhaskell# source bin/activate (venvhaskell) root@gcloudx:~/venvhaskell# | cs |
Haskell Stack을 다운로드한다. Ubuntu 의 경우 리눅스의 범용 설치법을 따른다. 아래 링크를 참조한다.
https://docs.haskellstack.org/en/stable/install_and_upgrade/#linux
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | (venvhaskell) root@gcloudx:~/venvhaskell# curl -sSL https://get.haskellstack.org/ | sh Detected Linux distribution: ubuntu Installing dependencies... 패키지 목록을 읽는 중입니다... 완료 의존성 트리를 만드는 중입니다 상태 정보를 읽는 중입니다... 완료 g++ is already the newest version (4:5.3.1-1ubuntu1). g++ 패키지는 수동설치로 지정합니다. gcc is already the newest version (4:5.3.1-1ubuntu1). libffi-dev is already the newest version (3.2.1-4). libgmp-dev is already the newest version (2:6.1.0+dfsg-2). libgmp-dev 패키지는 수동설치로 지정합니다. make is already the newest version (4.1-6). xz-utils is already the newest version (5.1.1alpha+20120614-2ubuntu2). git is already the newest version (1:2.7.4-0ubuntu1.3). gnupg is already the newest version (1.4.20-1ubuntu3.1). libc6-dev is already the newest version (2.23-0ubuntu9). libc6-dev 패키지는 수동설치로 지정합니다. zlib1g-dev is already the newest version (1:1.2.8.dfsg-2ubuntu4.1). 다음 패키지가 자동으로 설치되었지만 더 이상 필요하지 않습니다: apt-xapian-index aptitude-common ca-certificates-java dh-apparmor fonts-dejavu-extra g++-4.8 git-bzr git-remote-bzr gstreamer0.10-pulseaudio gyp libatk-wrapper-java libatk-wrapper-java-jni libatkmm-1.6-1 libboost-iostreams1.54.0 libboost-iostreams1.58.0 libc-ares-dev libc-ares2 libcairomm-1.0-1 libcanberra-gtk3-0 libcanberra-gtk3-module libcdr-0.1-1 libclass-accessor-perl libclass-load-perl libcolord1 libcolorhug1 libcwidget3 libdata-optlist-perl libdee-1.0-4 libegl1-mesa-drivers libelfg0 libept1.4.12 libgconf2-4 libgcrypt11-dev libgcrypt20-dev libghc-cgi-dev libghc-exceptions-dev libghc-extensible-exceptions-dev libghc-multipart-dev libghc-transformers-compat-dev libgif4 libglamor0 libglibmm-2.4-1c2a libgnutlsxx27 libgpg-error-dev libgphoto2-port10 libgsl2 libgtkmm-2.4-1c2a libgtkspell0 libicu52 libidl-2-0 libidl-common libimage-magick-perl libimage-magick-q16-perl libimobiledevice4 libintl-perl libio-string-perl libisl10 libjasper1 libjavascriptcoregtk-3.0-0 libjs-inherits libjs-node-uuid libllvm3.4 libmagick++-6.q16-5v5 libmagick++5 libmagickcore5 libmagickwand5 libmariadbclient18 libmysqlclient18 libnspr4 libnss3 libnss3-nssdb libodbc1 libopenvg1-mesa liborbit2 libpangomm-1.4-1 libparse-debianchangelog-perl libpgm-5.1-0 libplist1 libpoppler44 libpth20 librevenge-0.0-0 libsctp1 libsigc++-2.0-0c2a libspice-server1 libstdc++-4.8-dev libtelepathy-glib0 libunique-1.0-0 libupower-glib1 libusbmuxd2 libuv1-dev libv8-3.14-dev libv8-3.14.5 libvisio-0.1-1 libvpx1 libwebkitgtk-3.0-0 libwebkitgtk-3.0-common libwpd-0.10-10 libwpd-0.9-9 libwpg-0.2-2 libwpg-0.3-3 libxapian-1.3-5 libxapian22v5 libxcb-util0 libxfce4util6 libzeitgeist-2.0-0 libzmq3 linux-image-generic-lts-utopic lksctp-tools m17n-contrib node-abbrev node-ansi node-archy node-async node-block-stream node-combined-stream node-cookie-jar node-delayed-stream node-forever-agent node-form-data node-fstream node-fstream-ignore node-github-url-from-git node-glob node-graceful-fs node-gyp node-inherits node-ini node-json-stringify-safe node-lockfile node-lru-cache node-mime node-minimatch node-mkdirp node-mute-stream node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once node-osenv node-qs node-read node-read-package-json node-request node-retry node-rimraf node-semver node-sha node-sigmund node-slide node-tar node-tunnel-agent node-which nodejs-dev policykit-1-gnome python-bzrlib python-colorama python-crypto python-dbus python-dbus-dev python-distlib python-ecdsa python-httplib2 python-keyring python-launchpadlib python-lazr.restfulclient python-lazr.uri python-oauth python-paramiko python-secretstorage python-simplejson python-wadllib python-xapian python-xdg python-zeitgeist python3-colorama python3-distlib python3-html5lib python3-wheel python3-xapian1.3 rlwrap xfce4-mixer zeitgeist zeitgeist-core zeitgeist-datahub Use 'sudo apt autoremove' to remove them. 0개 업그레이드, 0개 새로 설치, 0개 제거 및 0개 업그레이드 안 함. Using generic bindist... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0 100 628 0 628 0 0 221 0 --:--:-- 0:00:02 --:--:-- 702 100 11.4M 100 11.4M 0 0 313k 0 0:00:37 0:00:37 --:--:-- 345k Installing Stack to: /usr/local/bin/stack... ------------------------------------------------------------------------------- Stack has been installed to: /usr/local/bin/stack WARNING: '/root/.local/bin' is not on your PATH. For best results, please add it to the beginning of PATH in your profile. (venvhaskell) root@gcloudx:~/venvhaskell# | cs |
경고 메시지를 해결하기 위해 /root/.bashrc 에 아래를 추가한다.
1 | export PATH="/root/.local/bin:$PATH" | cs |
HelloWorld.hs 파일을 다음과 같이 작성한다.
1 2 3 4 5 | #!/usr/bin/env stack -- stack --install-ghc runghc main :: IO () main = putStrLn "Hello World" | cs |
터미널에서 앞서 작성한 파일을 다음과 같이 실행한다. Hello World 가 출력됨을 볼 수 있다.
1 2 3 4 5 | (venvhaskell) root@gcloudx:~/venvhaskell# stack HelloWorld.hs Populated index cache. Downloaded ghc-8.0.2. Installed GHC. Hello World | cs |
https://docs.haskellstack.org/en/stable/install_and_upgrade/#ubuntu
728x90
'프로그래밍 Programming' 카테고리의 다른 글
하스켈 웹프레임워크 - Yesod 라우팅 구문 Routing Syntax (0) | 2017.11.30 |
---|---|
Haskell 웹프레임워크 Yesod 퀵 스타트 가이드 (0) | 2017.11.25 |
우분투 호스트이름 바꾸기 (0) | 2017.11.23 |
우분투에 pgAdmin 설치하기 How To Install pgAdmin on Ubuntu 14.04 (0) | 2017.11.18 |
우분투 14.04에 PostgreSQL 설치하기 How To Install and Use PostgreSQL on Ubuntu 14.04 (0) | 2017.11.18 |