Tuesday, May 8, 2007

Another Good OCaml Resource

There's a good collection of various OCaml tutorials available at http://www.ocaml-tutorial.org/. Worth a look.

Monday, April 30, 2007

An Article about OCaml

There's a new article by Yaron Minsky of Jane Street Capital fame (a Wall Street firm which uses OCaml extensively) in an (informal) online journal on functional programming called the Monad.Reader. You can check it out here. Just to tempt you, he at one point asserts:

"It has been my experience and the experience of most of the OCaml programmers I’ve known that the ob ject system in OCaml is basically a mistake."

Glad to hear that we're not alone.

Wednesday, April 25, 2007

The O Factor

And now for this week's challenge. At one point, the O'Reilly book warns: "A type constraint may make public a method declared with attribute private." Construct an example that demonstrates this pitfall.

Friday, April 20, 2007

Optional Assignment 3

Hey everyone,

For the next assignment, write an mli for your DAWG or trie to suppress unwanted globals. Then, write a wrapper module around the Set module so that it behaves the same way. Run some speed tests to see which one is faster.

Finally, convert your DAWG/trie to be more generic so that it can operate on types of arbitrary data. Your dawg should look something like:

module type WordType =
sig
type t
(* what other operations you need? Suffix? Equality? Common subsequence?*)
end

module DAWG = functor (W : WordType) ->
struct
type t
val create_dawg: unit -> t
(* etc *)
end

Saturday, April 14, 2007

Crack at Python 3000

This is a funny crack that Erich found somewhere. It's in reference to Guido's attack on a few core Lisp (and also ML) functions that he wants to remove from the next generation of Python. (http://lambda-the-ultimate.org/node/587 for information.)

The Fate Of LAMBDA in PLT Scheme v300
or
Lambda the Ultimate Design Flaw

About 30 years ago, Scheme had FILTER and MAP courtesy of Lisp hackers who missed them from their past experience. To this collection, Scheme added a lexically-scoped, properly-functioning LAMBDA. But, despite of the PR value of anything with Guy Steele's name associated with it, we think these features should be cut from PLT Scheme v300.

We think dropping FILTER and MAP is pretty uncontroversial; (filter P S) is almost always written clearer as a DO loop (plus the LAMBDA is slower than the loop). Even more so for (map F S). In all cases, writing the equivalent imperative program is clearly beneficial.

Why drop LAMBDA? Most Scheme users are unfamiliar with Alonzo Church (indeed, they don't even know that he was related to Guy Steele), so the name is confusing; also, there is a widespread misunderstanding that LAMBDA can do things that a nested function can't -- we still recall Dan Friedman's Aha! after we showed him that there was no difference! (However, he appears to have since lapsed in his ways.) Even with a better name, we think having the two choices side-by-side just requires programmers to think about their program; not having the choice streamlines the thought process, and Scheme is designed from the ground up to, as much as possible, keep programmers from thinking at all.

So now FOLD. This is actually the one we've always hated most, because, apart from a few examples involving + or *, almost every time we see a FOLD call with a non-trivial function argument, we have to grab pen and paper and imagine the *result* of a function flowing back in as the *argument* to a function. Plus, there are *more* arguments coming in on the side! This is all absurdly complicated. Because almost all the examples of FOLD we found in practice could be written as a simple loop with an accumulator, this style should be preferred, perhaps with us providing a simple helper function to abstract away the boilerplate code. At any rate, FOLD must fold.

--The PLT Scheme Team


-- David

Wednesday, April 11, 2007

DAWG Assignment

The purpose of the second assignment is to allow you to play with some of OCaml's imperative features, while further increasing your exposure to the language. The high level idea is to build a trie to store a list of words and then enable searching of this data structure. For those feeling more ambitious, the next step would be to convert the trie into a DAWG by merging common suffixes.

Your program should:
* Prompt for a filename
* Read all the word from that file
* Build the trie and/or DAWG
* Allow the user to query the data structure

Statistics about node counts (especially for the DAWG) would be neat, too.

For those interested in the value restriction mentioned in class today, there's a paper by entitled Simple Imperative Polymorphism by Andrew Wright which describes the various issues associated with static typing and imperative programming. It's available here in the handy-dandy ps.gz format (please let me know if you can locate a PDF).

Monday, April 9, 2007

Syllabus

As loosely outlined the first day of class, here's the syllabus for the quarter. Suggestions for changes are welcome!

April 4: Introduction and OCaml Crash Course
April 11: The Functional and Imperative Sides of OCaml
April 18: The Module System
April 25: OCaml Objects
May 2: Types in OCaml: Polymorphism and Inference
May 9: Concurrency in OCaml
May 16: Interfacing OCaml with C
May 23: ocamlp4, the debugger, and other cool tools
May 30: Guest Speaker! (TBA)
June 6: Final Presentations