Download mzscheme from PLT Scheme. If you are running a debian or Ubuntu distro, then alternatively type:
sudo apt-get install mzscheme
Download ghc from haskell.org. If you are running a debian or Ubuntu distro, then alternatively type:
sudo apt-get install ghc6 ghc6-doc
All required software is already installed on the department's machines. This means that you may use their machines locally on the third floor of Farris or work remotely on them via ssh. See the department's page on how to get an account for these machines and/or access them remotely.
emacs is the common choice for hacking in Scheme/Haskell. Its advantage over editors like vim when it comes to editing Scheme and Haskell code is that it can run background Scheme and Haskell REPL buffers and selectively move expressions from an emacs buffer into a REPL buffer.
(setq scheme-program-name "mzscheme -i -l defmacro.ss") (setq auto-mode-alist (cons '("\\.scm$" . scheme-mode) auto-mode-alist)) (put 'eval-expression 'disabled nil) (require 'font-lock) (global-font-lock-mode t) (show-paren-mode 1) (put 'upcase-region 'disabled nil) (load "/usr/share/emacs/site-lisp/haskell-mode/haskell-site-file.el") (setq haskell-program-name "ghci") (setq auto-mode-alist (cons '("\\.hs$" . haskell-mode) auto-mode-alist)) (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) ;; Choose indentation mode (the latter requires haskell-mode >= 2.5): (add-hook 'haskell-mode-hook 'turn-on-haskell-indent) ;;(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
Replace red paths with appropriate paths, which may be an absolute path if it is for a program not in your $PATH. For instance, on Windows, try c:/progra~1/mzscheme/mzscheme.exe or c:/progra~2/mzscheme/mzscheme.exe for mzscheme.
Unlike scheme-mode, haskell-mode is not included with emacs. Before haskell-mode will work, you will need to download it from projects.haskell.org and install it. Alternatively, if you are e.g. running debian or Ubuntu, I have provided a debian package for haskell-mode 2.7.0.
Command | Description |
---|---|
emacs foo.scm (from shell) | open file in emacs |
C-x C-s | save |
C-x C-c | quit |
C-g | abort command sequence |
C-b | backward character |
C-f | forward character |
C-p | up line |
C-n | down line |
C-x u | undo |
C-g (after undoing) | you can now undo your undo's, i.e., redo by now undoing |
Tab (in scheme-mode) | indent to the appropriate column |
Tab (in haskell-mode) | cycle through possible appropriate columns |
C-x 2 | split window into two |
C-x o | select other window |
M-x run-scheme | run scheme REPL in current window |
M-x run-haskell | run haskell REPL in current window |
C-c C-l | load file into REPL buffer |
Famous Lisp/Scheme hacker Paul Graham uses vim. And so do I. So if you do too, then you are in good company. Here is how you can get started hacking Scheme code in vim.
set ai filetype plugin on filetype indent on aug scheme au FileType scheme setl lispwords+=define-macro au FileType scheme setl lispwords-=if au FileType scheme nn <Tab> == au FileType scheme vn <Tab> = au FileType scheme setl inde=lispindent(v:lnum) au FileType scheme setl indk+=!<Tab> au FileType scheme let &l:makeprg = 'mzscheme -i -l defmacro.ss -e \(load\ \"' . shellescape(escape(expand('%'), '"\')) . '\"\)' au FileType scheme setl efm=%C%.%#:%*\\d:%*\\d:%.%#,%E%f:%l:%c:\ %m,%Z>%.%#,%-G%.%# aug END aug haskell au FileType haskell setl makeprg=ghci\ % aug END
Replace red paths with appropriate paths, which may be an absolute path if it is for a program not in your $PATH. This will allow you to load your scheme or haskell file inside of a new REPL environment by using :make. Note that, unlike with emacs, there is no REPL persistently running in a buffer, so the environment is not preserved in between instances of the interpreter. This file will also integrate mzscheme's and ghci's error output with vim's quickfix feature.
Note: if you are using a debian or Ubuntu distro, make sure that you have the vim package installed as opposed to only the vim-tiny package, which does not include the extras that we need.
We will be using the department's turnin script for turning in homework. You must be logged into a department machine to use it.
turnin cs357.hw1 knockel-hw1.scm # turn in file knockel-hw1.scm for assignment cs357.hw1 turnin -ls cs357.hw1 # list file(s) turned in for assignment cs357.hw1
turnin -rm cs357.hw1 # remove file(s) turned in for assignment cs357.hw1
The assignment name will always be cs357.hw# for homework #. Additionally, I have provided a sandbox assignment named cs357.sandbox. You may and are advised to play around with turning in files to the sandbox assignment before homework 1 is due to ensure that you know how to use the turnin script in time. I will not be accepting submissions via email.
A potential pitfall of the turnin script is that your turnin file's directory must be world executable and the file itself must be world readable. The recommended way of ensuring this is as follows:
cp knockel-hw1.scm /tmp cd /tmp chmod a+r knockel-hw1.scm turnin cs357.hw1 knockel-hw1.scm rm knockel-hw1.scm