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

RE: another take on hackers and painters



The beauty of type inference is that the inferred type is often even
more general than you think, in this case qsort can sort lists of any
value that is comparable (i.e. is an instance of the Ord class):

	qsort :: Ord a => [a] -> [a]

The downside of the example is that it does not capture what many
consider as the essence of quicksort namely that it sorts in-situ.

Erik

-----Original Message-----
From: Michael Vanier [mailto:mvanier@cs.caltech.edu] 
Sent: Tuesday, May 20, 2003 1:21 AM
To: sRp@srparish.net
Cc: pg@archub.org; ll1-discuss@ai.mit.edu
Subject: Re: another take on hackers and painters


I can't say I agree with your views on static typing, although many on
this
list will.  Have you ever used a really *nice* static type system like
in
ocaml or haskell?  They're not perfect, but they're miles ahead of what
most people think of when they think "static typing".  Here is quicksort
in
haskell:

    qsort :: [Int] -> Int
    qsort [] = []
    qsort (x : xs) = qsort [ y | y <- xs, y <= x ]
                     ++ [x] ++ qsort [ y | y <- xs, y > x ]

Beautiful enough for ya? ;-)

Mike

> Date: Tue, 20 May 2003 04:56:07 +0000
> From: Scott Parish <sRp@srparish.net>
> 
> I very much enjoyed the article Hackers and painters, but I think it
> only caught one side of the story, and after listening to the
discussion
> on ll1 i decided to answer it with this article:
> 
> Hackers: sketchers, drafters
>
http://blog.srparish.net/blog/articles/technical/hackers-sketchers-draft
ers.html
> 
> sRp
> 
> -- 
> Scott Parish
> http://srparish.net/
>