Re: [Haskell-cafe] List as input

2008-10-17 Thread leledumbo
So, what's the solution? This one: (l::[Ord]) - readLn doesn't work (because Ord isn't a type constructor). It doesn't even comply to Haskell 98 standard. I want to be able to read any list of ordered elements. -- View this message in context:

Re: [Haskell-cafe] List as input

2008-10-17 Thread Luke Palmer
On Fri, Oct 17, 2008 at 7:21 AM, leledumbo [EMAIL PROTECTED] wrote: So, what's the solution? This one: (l::[Ord]) - readLn doesn't work (because Ord isn't a type constructor). It doesn't even comply to Haskell 98 standard. I want to be able to read any list of ordered elements. What

Re: [Haskell-cafe] List as input

2008-10-17 Thread Dougal Stanton
On Fri, Oct 17, 2008 at 2:21 PM, leledumbo [EMAIL PROTECTED] wrote: So, what's the solution? This one: (l::[Ord]) - readLn doesn't work (because Ord isn't a type constructor). It doesn't even comply to Haskell 98 standard. I want to be able to read any list of ordered elements. I hope to

Re: [Haskell-cafe] List as input

2008-10-17 Thread Ryan Ingram
I can't think of a language that lets you do this; that is, allow you to input a list of any type as text. Some languages effectively encode the types in the parsing, for example in LISP, you know that 'foo is a symbol. It has a very limited set of data types and new types are described entirely

Re: [Haskell-cafe] List as input

2008-10-17 Thread David Leimbach
On Fri, Oct 17, 2008 at 6:21 AM, leledumbo [EMAIL PROTECTED]wrote: So, what's the solution? This one: (l::[Ord]) - readLn doesn't work (because Ord isn't a type constructor). It doesn't even comply to Haskell 98 standard. I want to be able to read any list of ordered elements. The

Re: [Haskell-cafe] List as input

2008-10-16 Thread David Leimbach
On Wed, Oct 15, 2008 at 9:53 PM, leledumbo [EMAIL PROTECTED]wrote: The compiler doesn't know what kind of list you are trying to read, sort, and print. So, the type must be specific? Then why it's possible to call the sorting function with any list? It isn't. The type of data in the

Re: [Haskell-cafe] List as input

2008-10-16 Thread leledumbo
... If there isn't enough information to set a concrete type at the call, type inference fails. This is what you get with strong typing. In my case, where does type inference fail? Strong typing is good, but quite confusing when combined with polymorphism. It isn't. The type of data in the

Re: [Haskell-cafe] List as input

2008-10-16 Thread Jason Dagit
On Thu, Oct 16, 2008 at 7:22 PM, leledumbo [EMAIL PROTECTED]wrote: ... If there isn't enough information to set a concrete type at the call, type inference fails. This is what you get with strong typing. In my case, where does type inference fail? Strong typing is good, but quite

Re: [Haskell-cafe] List as input

2008-10-16 Thread leledumbo
How about a list of functions from int to int? Hmm... it does make sense. -- View this message in context: http://www.nabble.com/List-as-input-tp19987726p20026222.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___

Re: [Haskell-cafe] List as input

2008-10-16 Thread Brandon S. Allbery KF8NH
On 2008 Oct 16, at 22:22, leledumbo wrote: ... If there isn't enough information to set a concrete type at the call, type inference fails. This is what you get with strong typing. In my case, where does type inference fail? Strong typing is good, but quite confusing when combined with

Re: [Haskell-cafe] List as input

2008-10-15 Thread Janis Voigtlaender
leledumbo wrote: module Main where import Data.List -- quicksort of any list qsort [] = [] qsort (x:xs) = qsort(filter(x) xs) ++ [x] ++ qsort(filter(=x) xs) -- optimized quicksort, uses middle element as pivot qsortOpt [] = [] qsortOpt x = qsortOpt less ++ [pivot] ++ qsortOpt greater

[Haskell-cafe] List as input

2008-10-15 Thread leledumbo
module Main where import Data.List -- quicksort of any list qsort [] = [] qsort (x:xs) = qsort(filter(x) xs) ++ [x] ++ qsort(filter(=x) xs) -- optimized quicksort, uses middle element as pivot qsortOpt [] = [] qsortOpt x = qsortOpt less ++ [pivot] ++ qsortOpt greater where pivot = x

Re: [Haskell-cafe] List as input

2008-10-15 Thread Toby Hutton
On Wed, Oct 15, 2008 at 5:44 PM, leledumbo [EMAIL PROTECTED] wrote: module Main where import Data.List -- quicksort of any list qsort [] = [] qsort (x:xs) = qsort(filter(x) xs) ++ [x] ++ qsort(filter(=x) xs) -- optimized quicksort, uses middle element as pivot qsortOpt [] = []

Re: [Haskell-cafe] List as input

2008-10-15 Thread Dan Weston
Google median order statistic. E.g. this is an interesting (and colorful) discussion: http://ocw.mit.edu/NR/rdonlyres/Electrical-Engineering-and-Computer-Science/6-046JFall-2005/60D030CD-081D-4192-9FB5-C220116E280D/0/lec6.pdf Toby Hutton wrote: On Wed, Oct 15, 2008 at 5:44 PM, leledumbo

Re: [Haskell-cafe] List as input

2008-10-15 Thread Toby Hutton
On Thu, Oct 16, 2008 at 9:01 AM, Dan Weston [EMAIL PROTECTED] wrote: Google median order statistic. E.g. this is an interesting (and colorful) discussion:

Re: [Haskell-cafe] List as input

2008-10-15 Thread leledumbo
The compiler doesn't know what kind of list you are trying to read, sort, and print. So, the type must be specific? Then why it's possible to call the sorting function with any list? I'm curious as to why taking the pivot from the middle is an 'optimized' version. Consider if it's used in a

Re: [Haskell-cafe] List as input

2008-10-15 Thread Brandon S. Allbery KF8NH
On 2008 Oct 16, at 0:53, leledumbo wrote: The compiler doesn't know what kind of list you are trying to read, sort, and print. So, the type must be specific? Then why it's possible to call the sorting function with any list? A function may have a polymorphic type; this allows its actual