[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can a functional language be sequential?

You might want to look at monads, particularly the monadic I/O system in
Haskell, which bring mutability and sequence into a purely functional
language through the back door, so to speak.  The idea is that if you
have some object type representing "the state of the universe" and
functions that can return multiple values, then you can have operations
like this:

(some_information, new_state_of_universe) =

newer_state_of_universe =
  put_information(some_other_information, new_state_of_universe);

Now, if there's only one copy of old_state_of_universe lying around,
then it can effectively represent a mutable world (e.g., a user giving
input to the program), and get_information can seize information from
that world and pass it around in a purely functional way.

Somebody who actually understands the academic research on monads might
be able to elaborate on this.

"[T]he determined real programmer can write FORTRAN programs in any
  --Ed Post
// seth gordon // sethg@ropine.com // http://ropine.com/sethg/cv.html //