Doesn't Haskell play in the purely functional league too?

Haskell is the example usually given, but I am told that Haskell has something called monads (don't ask me what they are; I don't have any idea) which allow state to be stored external to the function. Perhaps someone who knows more about Haskell could comment on this. I personally don't think that really keeps it from being a pure functional language, but to explain why I have to step aside and talk about another language...

The other usual example is Lisp (or a variant, such as Scheme), but I really don't consider Lisp and its kin to be functional per se, though they have stuff in common with functional languages, and if you start throwing around lambda expressions your program can be very functional. But I would say that functions in lisp are just a special kind of list; any given list may or may not be valid as a function, but every function is a list. Lisp is fundamentally list-oriented, then, and functions are just one important kind of list. This makes it possible to program in lisp according to a functional paradigm, but it is also possible to not do that -- for example, to use a procedural paradigm, if one chooses. I have done so in a number of cases. (Just one example: most .emacs files are very procedural in nature.) In that respect, lisp is like Perl: it is a general-purpose language, not tied to one way of doing things.

Haskell, OTOH, is very much tied to one paradigm, so it could be argued that it is purely functional indeed, because even if these monad thingies give it the ability to store state external to a function, it still is approaching the issue from a functional perspective at some level. I have not seen anyone claim to have used a procedural or object-oriented paradigm when writing in Haskell. If state is stored, it is stored for the benefit of functions, which are the main focus. In lisp (or Perl), I can write a program that consists entirely of one big main routine which does not return any significant value at all. Sure, it calls some builtin functions, but that's also true in C, BASIC, and even assembly language, and nobody is going to call those functional.

So I think when we decide whether a language is a pure functional language, that may be the question to consider: does it allow for completely abandoning the functional paradigm and writing code entirely another way (e.g., procedural or OO). If it does, the language may have functional bits, but it is not functional per se.

OTOH, if we apply the analogous criterion to OO, I do not think I know of a single pure object-oriented language. All the OO languages I know about, it is possible to write procedural code if you want. Unless you count data description languages (such as POV or XML), but that's different.


sub H{$_=shift;while($_){$c=0;while(s/^2//){$c++;}s/^4//;$ v.=(' ','|','_',"\n",'\\','/')[$c]}$v}sub A{$_=shift;while ($_){$d=hex chop;for(1..4){$pl.=($d%2)?4:2;$d>>=1}}$pl}$H= "16f6da116f6db14b4b0906c4f324";print H(A($H)) # -- jonadab

In reply to Re: Why Closures? by jonadab
in thread Why Closures? by mothra

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.