On Thu, 2004-07-01 at 17:01, Crypt Master wrote: > I consider myself a pretty good imperative programmer, been at it for > decades, and am tryibng my hand at Haskell now. Unfrituantly I am not > "getting" it all that quickly despite having the multimedia haskell book.
[snip] > The take operator doesnt work on this. from hugs: > > HAGA> take 5 gaSolutionSpace [1,2,3,4,5] > ERROR - Type error in application > *** Expression : take 5 gaSolutionSpace [1,2,3,4,5] > *** Term : take > *** Type : Int -> [e] -> [e] > *** Does not match : a -> b -> c -> d What this error message is telling you is this: * The 'take' function wants two parameters, an Int and a list of some type '[e]'. It will give you back a list of the same type * You have given it three parameters, or to put it another way you are using 'take' as if it had type 'a -> b -> c -> d' (for some a,b,c & d) The solution then is to just pass two arguments. How do you do that? In what you've written can you see that you're passing 3 arguments? take 5 gaSolutionSpace [1,2,3,4,5] People say function application in Haskell is written without brackets but this can be misleading, here you do need brackets to indicate that 'gaSolutionSpace [1,2,3,4,5]' is one argument and not two. So you should write: take 5 (gaSolutionSpace [1,2,3,4,5]) Now there are just two parameters, where the second parameter is another expression rather than a simple variable or constant. If your gaSolutionSpace takes a list type and returns a list type then this will be well typed, and hugs will not complain. Duncan _______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe