Re: Haskell-Cafe digest, Vol 1 #342 - 1 msg
I want to read a file's content into a string. content :: FilePath -> String content f = readFile f But when there is a type error: Type error in explicitly typed binding *** Term : content *** Type : FilePath -> IO String *** Does not match : FilePath -> String How can I solve it? Thanks. Zhe
"Zhe Fu" <fuzhezheng@hotmail.com> writes:
But when there is a type error: [...] How can I solve it?
I often remove the type declaration, load the code in GHCi or Hugs, and do a :t my_function. The interpreter then tells me what /it/ thinks is the type, and quite often it is smarter than I am :-) (You can also use :i, which is somewhat more informative) -kzm -- If I haven't seen further, it is by standing in the footprints of giants
participants (2)
-
ketil@ii.uib.no -
Zhe Fu