tweaks
[lambda.git] / topics / week9_using_the_juli8_libraries.mdwn
index bf1abc7..ee662c3 100644 (file)
 
 ## Using the Juli8 Libraries ##
 
-In addition to the fine programming language Kapulet, which doesn't yet exist in a form you can actually execute --- though the full-featured interpreter we provided last week is a good start --- I decided it would be useful to have a collection of basic libraries for our teaching (and other) purposes, that brought OCaml, Haskell, and the Scheme implementations we recommend, more onto even footing. Of course there are fundamental differences between these languages, such as the lack of types in Scheme (though both Racket and Chicken have some facility for working with types in extensions), or the default lazy evaluation strategy in Haskell. But there are also many simply accidental differences between the languages too, in that this one provides a library function doing so-and-so, but the other one doesn't, or calls it by a different name. The Juli8 collection of libraries is aimed to reduce these differences, to make it easier to move back and forth between the languages, and also to just make some of the languages generally easier to use (from my perspective). Juli8 will eventually have components that you can install into each of Haskell, OCaml, Racket, and Chicken. For the moment, OCaml is the most developed of these, and Haskell a bit, with the Scheme components deferred for another time.
+In addition to the fine programming language Kapulet, which doesn't yet exist in a form you can actually execute --- though the full-featured interpreter we provided last week (LINK) is a good start --- I decided it would be useful to have a collection of basic libraries for our teaching (and other) purposes, that brought OCaml, Haskell, and the Scheme implementations we recommend, more onto even footing. Of course there are fundamental differences between these languages, such as the lack of types in Scheme (though both Racket and Chicken have some facility for working with types in extensions), or the default lazy evaluation strategy in Haskell. But there are also many simply accidental differences between the languages too, in that this one provides a library function doing so-and-so, but the other one doesn't, or calls it by a different name. The Juli8 collection of libraries is aimed to reduce these differences, to make it easier to move back and forth between the languages, and also to just make some of the languages generally easier to use (from my perspective). Juli8 will eventually have components that you can install into each of Haskell, OCaml, Racket, and Chicken. For the moment, OCaml is the most developed of these, and Haskell a bit, with the Scheme components deferred for another time.
 
-Juli8 tries to give OCaml more-or-less the same functionality that you have in Haskell's Maybe, List, and Monad libraries, as well as a few others. It doesn't try for an exact match, and it doesn't strictly use the same names as Haskell does. I've aimed also to at least stay close to the existing OCaml naming patterns, and also the Scheme naming patterns when they are salient to me.
+Juli8 tries to give OCaml more-or-less the same functionality that you have in Haskell's Maybe, List, and Monad libraries, as well as a few others. It doesn't try for an exact match, and it doesn't strictly use the same names as Haskell does. I've aimed to at least stay close to the existing OCaml naming patterns, and also the Scheme naming patterns when they are salient to me.
 
-First we'll give instructions on how to install Juli8 into your existing Haskell and/or OCaml setups. Then we'll give instructions on how to use the non-monadic parts of the Juli8 libraries for OCaml. We discuss how to use the monadic parts of the Juli8 libraries for OCaml [[here]]. At the end, we say a little bit about what Juli8 provides you if you're using Haskell.
+First we'll give instructions on how to install Juli8 into your existing Haskell and/or OCaml setups. Then we'll give instructions on how to use the non-monadic parts of the Juli8 libraries for OCaml. We discuss how to use the monadic parts of the Juli8 libraries for OCaml here (LINK). At the end, we say a little bit about what Juli8 provides you if you're using Haskell.
 
-## Setting up OCaml ##
+## Setting up OCaml in general, and for use with Juli8 ##
 
 1. In our instructions for installing OCaml, some of the strategies involved installing the OPAM package manager. (This doesn't appear to be available for Windows.) If you did install OPAM, then we recommend typing the following commands inside a terminal session (that is, *not* inside an OCaml session, but inside the prompt where you'd start OCaml by typing `ocaml`).
 
@@ -29,6 +29,8 @@ First we'll give instructions on how to install Juli8 into your existing Haskell
         opam upgrade
         opam install delimcc
 
+    We'll comment on the `delimcc` package in a moment.
+
     We also recommend upgrading to one of the more recent versions of OCaml. This gets you the most recent stable release:
 
         opam switch 4.02.1 && opam install --switch=4.02.1 delimcc && eval `opam config env`
@@ -41,11 +43,11 @@ First we'll give instructions on how to install Juli8 into your existing Haskell
 
         module type SOMETHING = Monad.OPTION
 
-    as I directed you [[elsewhere]], you can instead just type:
+    as I directed you elsewhere (LINK), you can instead just type:
 
         #show Monad.OPTION
 
-2. The program that starts up when you type `ocaml` is OCaml's Standard "Toplevel" Interactive Interpreter. There's an alternative interactive interpreter that you can try out, which some people like. It's called utop and [you can read about it here](https://github.com/diml/utop) or [here](https://opam.ocaml.org/blog/about-utop). To install it, you can just type `opam install utop`. I'm not so crazy about it myself. But I prefer to use *some* kind of helper program with OCaml's Standard Toplevel, because the Standard Toplevel itself doesn't let you scroll back through commands you typed previously, has only very rudimentary facilities for editing a line if you made a mistake and so on. One virtue of utop is that it does those things better, but there are also other ways to do them better. What I use is a wrapper program called `rlwrap`. Here are instructions for how to install that:
+2. The program that starts up when you type `ocaml` is OCaml's Standard "Toplevel" Interactive Interpreter. There's an alternative interactive interpreter that you can try out, which some people like. It's called **utop** and [you can read about it here](https://github.com/diml/utop) or [here](https://opam.ocaml.org/blog/about-utop). To install it, you can just type `opam install utop`. I'm not so crazy about it myself. But I prefer to use *some* kind of helper program with OCaml's Standard Toplevel, because the Standard Toplevel itself doesn't let you scroll back through commands you typed previously, has only very rudimentary facilities for editing a line if you made a mistake and so on. One virtue of utop is that it does those things better, but there are also other ways to do them better. What I use is a wrapper program called **rlwrap**. Here are instructions for how to install that:
 
     > First, I had to upgrade the version of the "GNU readline" library on my computer. My Mac with System 10.9.5 has a version of that library, but it's too old to use with recent versions of `rlwrap`. So I downloaded [the source code for GNU readline](http://ftp.gnu.org/gnu/readline/readline-6.3.tar.gz). Double click the downloaded archive to expand it, if your browser doesn't do that automatically. Then go inside the `readline-6.3` folder in a Terminal. On a Mac, you can click on the folder in the Finder and do a Copy (or cmd-C). Then open a Terminal and type `cd` followed by a space then do a Paste (cmd-V). Then press <code><i>return</i></code>. Once you're inside the `readline-6.3` folder, type this command in the Terminal:
 
@@ -57,9 +59,9 @@ First we'll give instructions on how to install Juli8 into your existing Haskell
 
     If that all completes without errors, then you have gotten `rlwrap` installed. Congratulations. To use it, you just will now type `rlwrap ocaml ...` wherever before you would ordinarily type `ocaml ...` This is just to make interactive OCaml sessions nicer. To compile code with `ocamlc ...` and so on, you don't use `rlwrap` for that. (If you see error messages of the form `-bash: rlwrap: command not found`, then you should make sure that you have a `.bash_profile` or `.bashrc` in your `$HOME` directory which has a line containing something like `export PATH="$HOME/bin:$HOME/Library/Haskell/bin:$PATH"`. Then maybe start up a new Terminal.)
 
-    Some key commands you can now use are:
+    Some keycommands you can now use are:
 
-    * BLAH
+    * TODO
 
     If you want to customize `rlwrap` or these keycommands, you can read the documentation at `man rlwrap` and `man readline`, and also look into the Preferences of your Terminal program. (On the Mac, look under Terminal menu/Preferences/Keyboard tab.) This gets complicated quickly, but those are the places to start looking if you want to experiment. You should of course also read around on the web, rather than just changing these blindly.
 
@@ -81,7 +83,7 @@ First we'll give instructions on how to install Juli8 into your existing Haskell
 
         #use "juli8.ml";;
 
-4. Next create a folder in your `$HOME` directory named `.juli8`. Download the Juli8 code from [[here]]. That link will no doubt be updated frequently in April and May 2015. The current version is: 1.2, posted 4 April 2015. Copy the contents of the `Juli8` folder that you downloaded into the `$HOME/.juli8` folder that you created.
+4. Next create a folder in your `$HOME` directory named `.juli8`. Download the Juli8 code from [[here]] (LINK). That link will no doubt be updated frequently in April and May 2015. The current version is: 1.2, posted 4 April 2015. Copy the contents of the `Juli8` folder that you downloaded into the `$HOME/.juli8` folder that you created.
 
     Now whenever you start up OCaml, the Juli8 OCaml libraries (including their monad components, which we'll be making extensive use of) will automatically be loaded. <!-- If later you want to load Oleg's Delimcc library, type `#load "delimcc.cma";;` then use the `Delimcc` module. -->
 
@@ -94,5 +96,5 @@ Will add...
 
 ## Using the Juli8 libraries with OCaml ##
 
-Will add here some guidance on using the non-monadic parts of the Juli8 library. For the monadic part, [[see here]].
+Will add here some guidance on using the non-monadic parts of the Juli8 library. For the monadic part, [[see here]] (LINK).