Chris' improvement to tc with #
[lambda.git] / juli8.mdwn
index e400162..b2689af 100644 (file)
@@ -26,15 +26,15 @@ Below, we'll give instructions on how to install Juli8 into your existing OCaml
 
         opam switch 4.02.0+improved-errors && opam install --switch=4.02.0+improved-errors delimcc && eval `opam config env`
 
-    Installing the `delimcc` library gives you Oleg's Delimited Continuation library for OCaml, which we will encourage you to play around with later in the term. It's not essential to have it, though. There are some advantages to using one of the 4.02.x versions of OCaml, though, rather than the 4.01.0 version I think most of us ended up installing. One advantage is that now you can use the special <code>#show <i>symbol</i></code> command in OCaml sessions, which works like Haskell's special <code>:info <i>symbol</i></code> inside a GHCi session. Then for example, instead of having to type:
+    Installing the `delimcc` library gives you [Oleg's Delimited Continuation library for OCaml](http://okmij.org/ftp/continuations/implementations.html), which we will encourage you to play around with later in the term. <!-- see also http://stackoverflow.com/questions/14431257 --> It's not essential to have it, though. There are some advantages to using one of the 4.02.x versions of OCaml, though, rather than the 4.01.0 version I think most of us ended up installing. One advantage is that now you can use the special <code>#show <i>symbol</i></code> command in OCaml sessions, which works like Haskell's special <code>:info <i>symbol</i></code> inside a GHCi session. Then for example, instead of having to type:
 
         module type SOMETHING = Monad.OPTION
 
-    as [[I directed you elsewhere|/topics/week9_using_the_monad_library]], you can instead just type:
+    as [[I directed you elsewhere|/topics/week9_using_the_monad_library/#index1h2]], 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|/topics/week8_monads_and_modules/#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. (Kyle is using OCaml on Cygwin on Windows, and there it *looks* like rlwrap is already installed; on the other hand, it doesn't seem to be working. The issue might not be with rlwrap, but rather that his Terminal is not passing the appropriate keypresses through to the shell session it's hosting.)
 
     > 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:
 
@@ -55,18 +55,18 @@ Below, we'll give instructions on how to install Juli8 into your existing OCaml
     * `esc` + `D` will delete one word to the right of the cursor position
     * `^U` will delete from the cursor position leftwards all the way to the start of the line
     * `^K` will delete from the cursor position rightwards all the way to the end of the line
-    * Control+`-` will undo one editing command or sequence of typed characters
+    * Control-`minus` will undo one editing command or sequence of typed characters
     * `esc` + `R` will (usually) erase the whole line (undoing everything)
     * `^A` moves the cursor to the start of the line
     * `^E` moves the cursor to the end of the line
     * `^B` and `^F` work like left and right arrows
     * `esc` + `B` and `esc` + `F` move left and right a whole word at a time (on the Mac, Option-`left` and Option-`right` do the same)
-    * Control-`]`+`x` will move the cursor rightwards to the next `x` character on the line (similarly for other characters in place of `x`). You can do the same leftwards by typing `esc`+Control-`]`+`x`. You can move to the second-next `x` character by typing `esc`+`2`+Control-`]`+`x`. This is all pretty cumbersome.
+    * Control-`]` + `x` will move the cursor rightwards to the next `x` character on the line (similarly for other characters in place of `x`). You can do the same leftwards by typing `esc` + Control-`]` + `x`. You can move to the second-next `x` character by typing `esc` + `2` + Control-`]` + `x`. This is all pretty cumbersome.
     * `^L` clears the screen
-    * `up`/`down` arrows let you scroll through previous lines you typed (also `^P` / `^N`)
-    * `^R` lets you search through previous lines you typed for a matching substring; to refine the search keep making the substring longer, or type `^R` again to find an earlier match. Type `esc` to exit the search and edit the currently showing command line. Type `^G` to exit the search with a blank command line.
+    * `up` / `down` arrows let you scroll through previous lines you typed (also `^P` / `^N`)
+    * `^R` lets you search through previous lines you typed for a matching substring; to refine the search keep making the substring longer, or type `^R` again to find an earlier match. Type `return` to use the currently showing match, or `esc` or an arrow key to exit the search and edit the currently showing match. Type `^G` to exit the search with a blank command line.
 
-    If you create a file named `$HOME/.inputrc` with the contents:
+    If you create a file named `$HOME/.inputrc` which contains:
 
         set blink-matching-paren on
 
@@ -91,7 +91,7 @@ Below, we'll give instructions on how to install Juli8 into your existing OCaml
 
         #use "juli8.ml";;
 
-4. Next create a folder in your `$HOME` directory named `.juli8`. Download the Juli8 code from [[here|/code/Juli8-v1.2.tgz]]. 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|/code/Juli8-v1.6.tgz]].** That link will no doubt be updated frequently in April and May 2015. The current version is: 1.6, posted 13 April 2015. Copy the contents of the `Juli8` folder that you downloaded into the `$HOME/.juli8` folder that you created. (So `$HOME/.juli8` should contain folders `haskell`, `ocaml`, and so on.)
 
     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. -->
 
@@ -104,7 +104,7 @@ First, at the top level of your session --- that is, not inside any module --- y
 
 You also get the functions `const`, `flip`, `fix`, `swap`, `curry`, `uncurry`, `even`, and `odd` that work like their Haskell counterparts. <!-- Data.function.fix, Data.Tuple.swap -->
 
-These functions have Haskell counterparts with slightly different names: OCaml's `pair` is Haskell's `(,)`; OCaml's `sign` is Haskell's `signum`; OCaml's `pow (x : int) (n : int)` is Haskell's `x^n`; OCaml's `ignore(expr1); expr2` is like `let _ = expr1 in expr2` in Haskell (and also in OCaml).
+These functions have Haskell counterparts with slightly different names: OCaml's `pair` is Haskell's `(,)`; OCaml's `sign` is Haskell's `signum`; OCaml's `pow (x : int) (n : int)` is Haskell's `x^n`; OCaml's `ignore(expr1); expr2` is like `let _ = expr1 in expr2` in Haskell (and also in OCaml). When `expr1` returns `()`, you can omit the `ignore(...)` and just say `expr1; expr2`. Because these sequences with semicolons can parse differently than you expect, it's generally a good idea to surround them with parentheses or with `begin ... end` which in OCaml is just a syntactic variant of parentheses.
 
 Note that OCaml already came with the following functions that work like their Haskell counterparts: `max`, `min`, `not`, `&&`, `||`, `succ`, `abs`, `fst`, and `snd`. OCaml's infix operators `mod` and `/` work like Haskell's `rem` and `quot`, not like Haskell's `mod` and `div`. (These behave the same when both arguments are positive.)
 
@@ -185,15 +185,15 @@ Does Haskell have ref cells, you ask? Well it has `STRef`s and `IORef`s, these a
 
 ### Option ###
 
-Juli8 provides an `Option` module (this same module can also be found at `Monad.Option`). This provides a number of functions that you can see by typing `#show Monad.Option` if you're running OCaml version 4.02 or above. For earlier versions of OCaml, type `module Something = Option;;` to see the same result. A few of the functions from the `Option` module are also currently exported to be available at the top level. Thus you can simply say `is_some x` instead of `Option.is_some x`. But if you're not sure which are available in this way, just play it safe and use the preferatory `Option.`.
+Juli8 provides an `Option` module (there's also a module `Monad.Option` that only exposes the monadic interface). This provides a number of functions that you can see by typing `#show Option` if you're running OCaml version 4.02 or above. For earlier versions of OCaml, type `module Something = Option;;` to see the same result. A few of the functions from the `Option` module are also currently exported to be available at the top level. Thus you can simply say `is_some x` instead of `Option.is_some x`. But if you're not sure which are available in this way, just play it safe and use the preferatory `Option.`.
 
 ### List ###
 
-Juli8 provides a `List` module that can also be found at `Monad.List`, and that replaces the standard OCaml `List` module, which is a bit skimpy. The official `List` module is still available at `Std.List`, but all of its functionality is present in Juli8's `List` module, albeit sometimes under slightly different names. To see what's in the `List` module that Juli8 provides, type `#show List` in OCaml version >= 4.02. Many of the functions here parallel functions from the Haskell libraries.
+Juli8 provides a `List` module that replaces the standard OCaml `List` module, which is a bit skimpy. The official `List` module is still available at `Std.List`, but all of its functionality is present in Juli8's `List` module, albeit sometimes under slightly different names. To see what's in the `List` module that Juli8 provides, type `#show List` in OCaml version >= 4.02. Many of the functions here parallel functions from the Haskell libraries.
 
-As with the `Option` library, a few of the functions are also currently exported to be available at the top level.
+As with the `Option` library, a few of the functions are also currently exported to be available at the top level. Also as with `Option`, there's additionally a module `Monad.List` that only exposes the monadic interface.
 
-Without trying to give an exhaustive explanation of these functions, here are a few comments.
+Without trying to give an exhaustive explanation of the `List` functions, here are a few comments.
 
 Juli8's `head` and `tail`, like OCaml's official `List.hd` and `List.tl`, both raise an error if applied to an empty list. However, Juli8 also provides a `tail'` function that returns `[]` when applied to the empty list. (Compare `pred'`, described above.) There are analogous pairings between `take`,`drop`, and `split` on the one hand, and `take'`, `drop'`, and `split'` on the other.
 
@@ -228,6 +228,7 @@ Juli8 provides a `Random` module that replaces the standard OCaml `Random` modul
 
         cabal update
         cabal install --user cabal-install ghc-paths semigroups hoogle
+        hoogle data
 
     <!-- also haskell-docs for :whatis command, but I'm not sure yet this is worth it. -->
 
@@ -291,6 +292,8 @@ If everything works, then when you start up GHCi, you should see a prompt like t
 
 Note that the GHCi command line already by default accepts the special keycommands described under item 2 in the Setting up OCaml section above. Additionally, if you type just the start of a command and then press `Tab`, GHCi will attempt to figure out what you started to type and finish the word for you.
 
+<!-- One difference is that in GHCi, you clear an `^R` search with `^C` rather than `^G`. -->
+
 
 ## What do I get from Juli8 for Haskell? ##