Hello I have a file with 100 lists, with 100 ints. I have to read the file and apply the map and sort functions on lists. II did it to read file: learquivo :: FilePath -> IO ([[Int]]) learquivo s = do conteudo <- readFile s return (read conteudo) But now applying the sort, the error appears: <interactive>:1:5: Couldn't match expected type `[a]' against inferred type `IO [[Int]]' how can I fix? Thanks
On Mon, 18 Oct 2010, Gilmara Pompelli wrote:
Hello
I have a file with 100 lists, with 100 ints.
I have to read the file and apply the map and sort functions on lists.
II did it to read file:
learquivo :: FilePath -> IO ([[Int]]) learquivo s = do conteudo <- readFile s return (read conteudo)
But now applying the sort, the error appears:
Where do you apply 'sort' ? You mean sort learquivo ? It must be fmap sort learquivo .
I have a file with 100 lists, with 100 ints.
I have to read the file and apply the map and sort functions on lists.
II did it to read file:
learquivo :: FilePath -> IO ([[Int]]) learquivo s = do conteudo <- readFile s return (read conteudo)
But now applying the sort, the error appears:
<interactive>:1:5: Couldn't match expected type `[a]' against inferred type `IO [[Int]]'
how can I fix?
You did not even say how you produced that error. Assuming you are in GHCi, you want to do: m <- learquivo "miarquivo" :t m (Think of the interactive GHCi prompt as inside a big ``do''.) Hope this helps! Wolfram
participants (3)
-
Gilmara Pompelli -
Henning Thielemann -
kahl@cas.mcmaster.ca