hi,
i havent had much experience with Haskell although i have been
following its development for about 1 or 2 years...
> g :: [String] -> String
> g a = a!!0
>
> f :: String
> f = do
> x <- [""]
> return (g x)
>
> error message:
> Couldn't match `Char' against `String'
> Expected type: Char
> Inferred type: String
> In the application `g x'
> In the first argument of `return', namely `(g x)'
>
the problem with the above piece of code (the way I see it anyway) is
that 'x' is of type String and not [String]. I think it is of type
'String' because Lists form a monad and the 'do' notation used above
extracts the value from the monad, i.e. [""] is of type M a, where
'M' is the monad of lists and 'a' is the type String.
so when trying to apply 'g' to 'x' a type errro occurs. I am not too
sure what the 'expexted' bit in the error above means, but i suppose
it is what you would get if you applied 'g' to 'x' anyways (ignoring
the type declaration for 'g').
hugs also produces an error:
ERROR "test.hs" (line 5): Type error in application
*** Expression : g x
*** Term : x
*** Type : [Char]
*** Does not match : [String]
which to makes sence.
hope this helps
yavor
--
iavor s. diatchki
university of cape town
email: [EMAIL PROTECTED]
web: http://www.cs.uct.ac.za/~idiatchk