[Haskell-cafe] Trapped by the Monads

Bill Wood william.wood3 at comcast.net
Tue Sep 20 15:15:08 EDT 2005


   . . .
> Another thing I noticed in my nano-experience of Haskell is the Maybe 
> monad. This is interesting because it's a bit like a hybrid variables. 
> If you look at a book like "Writing Solid Code" (or is it "Code 
> Complete", I can't remember now) which examine C style, they basically 
> scorn the use of hybrid variables. However, I read in something like 
> "Thinking Forth" (or maybe it was just a comment I saw atrributed to 
> Charles Moore, the inventor of Forth), who actually advocated hybrid 
> variables.

Could you briefly elaborate on what you mean by "hybrid variables"?

> It would be interesting to see how far the notion of "Haskell as Forth" 
> can go. Can Haskell make a better Forth than Forth can, or does it miss 
> some things which are quite natural in Forth.

I've always thought that there was a pretty natural correspondence
between Forth and FLs (functional languages); words that pop args from
the stack, compute, and push the results correspond to "pure" code, and
words that do IO, fetch and assign variables, etc. correspond to the
imperative code.

The facts that 1) the innards of the Forth machine are exposed to the
programmer and 2) that everything in Forth is a word make seamless
language extension easy; I don't think the same can be said for FLs.

On the other hand, recursion is difficult in Forth, and
interpretation-as-you-read make higher-order functions difficult (I
never saw any serious attempts at HOFs).

I suspect it's a levels-of-abstraction thing; after all, the Forth
environment could be viewed as the ideal stack machine upon which to
implement FLs and block-structured languages.

 -- Bill Wood
    bill.wood at acm.org




More information about the Haskell-Cafe mailing list