From: jim Date: Sun, 5 Apr 2015 23:18:49 +0000 (-0400) Subject: various X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=commitdiff_plain;h=dcfd0176ecde3a8430e464896dcdea4046e9a93a various --- diff --git a/juli8.mdwn b/juli8.mdwn index e4001620..c3647c7e 100644 --- a/juli8.mdwn +++ b/juli8.mdwn @@ -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.2.tgz]]. That link will no doubt be updated frequently in April and May 2015. The current version is: 1.3, posted 5 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. @@ -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. -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