実行環境のインストール
とりあえず、実行環境がなければ始まらない。
前回(http://d.hatena.ne.jp/soybeens/20060814)のページを引き続き参考にして、WinHugsをインストール。
早速起動。
・・・操作方法がわからん。
とりあえず、ヘルプが見たければ「:?」と打てと書いあるので、入力。
LIST OF COMMANDS: Any command may be abbreviated to :c where c is the first character in the full name. :load <filenames> load modules from specified files :load clear all files except prelude :also <filenames> read additional modules :reload repeat last load command :edit <filename> edit file :edit edit last module :module <module> set module for evaluating expressions <expr> evaluate expression :type <expr> print type of expression :? display this list of commands :set <options> set command line options :set help on command line options :names [pat] list names currently in scope :info <names> describe named objects :browse <modules> browse names exported by <modules> :main <aruments> run the main function with the given arguments :find <name> edit module containing definition of name :cd dir change directory :gc force garbage collection :version print Hugs version :quit exit Hugs interpreter
実行までの手順は、
- Haskellのソースをテキストで.hsの拡張子を付けて保存
- loadコマンドでファイル読み込み
- 関数名入力で実行
ってな感じ。
editコマンドを使えば、オプションで設定したテキストエディタが起動する。
さっそく、プログラムを入力
add x y = x + y
loadして、実行。
Hugs>:load test.hs Main>add 5 6 11
うん、とりあえず実行はできてるみたいだ。