Is Haskell a Lisp?

2020-02-03 09:31发布

I've been reading The Haskell Road to Logic, Maths and Programming by Doets and Eijck 2004. It seems to be a well respected book, but I was struck when it claims that Haskell is a member of the Lisp family. Is this accurate? I would characterise Lisps with s-expressions, impure functions, and lists as the only composite data structure. Haskell has none of that. What justification is there for that claim?

9条回答
闹够了就滚
2楼-- · 2020-02-03 10:03

What people define as a lisp varies. The original specification for a lisp didn't mention macros at all and only defined a small list of primitive function, which, if my memory serves me, are the following:

  • cons
  • car
  • cdr
  • cond
  • eq
  • atom
  • and
  • or
  • not
  • nil

This might not be the full list, or it might have few additional members, but in any case, John McCarthy's original specification was very small.

If you define a lisp as any language that defines all of those functions, then most modern languages are lisps, including haskell.

A more strict and modern definition of a lisp is as follows:

  • eager evaluation
  • dynamic typing
  • impure functional
  • macros
  • focus on lists as primary data structure

Haskell doesn't fit the first 3, it's macros (template haskell) don't follow the code-is-data paradigm, and while lists are very important, they're not the primary data structure.

So I would say no, Haskell is not a lisp.

查看更多
Fickle 薄情
3楼-- · 2020-02-03 10:05

Haskell is not lisp of course. Everyone has his own understanding what the heck "lisp" is. IMHO lisp is a language where the source code is a valid structure in that same language. Haskell source code is not a valid structure in haskell, hence they have to have a separate syntax (Haskell Template) to manipulate their own source code.

But there's at least one interesting feature in haskell that reminds me of lisp. Its the syntax of function calls: func args1 agr2 arg3. Lisp has EXACTLY the same syntax: (func args1 agr2 arg3). In fact you can include outside parens in haskell too. All other algol family languages introduce parens and commas between function name and arguments.

查看更多
趁早两清
4楼-- · 2020-02-03 10:10

I think that it is a stretch to consider Haskell as a member of the LISP family, but I suspect the reasoning goes something like this...

When classifying programming languages, it is meaningful to divide them into two groups: those descended from FORTRAN and those that are not. In 1958, the "not FORTRAN group" pretty much meant LISP (at least, among the languages that are not extinct today). So, for a time, the programming language family tree had two main branches: the FORTRAN descendants and the LISP descendants. If those are the only two choices, then I would put Haskell into the LISP branch.

However, many commentators consider languages like ML, Prolog and APL to have arisen "out of the blue" -- introducing sufficiently distinct paradigms to merit lineages unto themselves. Haskell is clearly kin to ML.

As examples of such classifications, see the following programming language family trees:

O'Reilly's Programming Language Poster

Computer Languages Timeline at levenez.com

HOPL: an interactive Roster of Programming Languages (Haskell Entry)

查看更多
登录 后发表回答