[Haskell-begin] Using read, reads...

Rafael Gustavo da Cunha Pereira Pinto rafaelgcpp at gmail.com
Mon Jul 21 18:47:10 EDT 2008


Thanks, but what I needed was a line-by-line analyser.

I ended up with Felipe's solution.

Thank you all!

On Mon, Jul 21, 2008 at 16:14, Henk-Jan van Tuyl <hjgtuyl at chello.nl> wrote:

> On Mon, 21 Jul 2008 06:51:27 +0200, Felipe Lessa <felipe.lessa at gmail.com>
> wrote:
>
>> On Sun, Jul 20, 2008 at 10:30 PM, Rafael Gustavo da Cunha Pereira
>> Pinto <rafaelgcpp at gmail.com> wrote:
>>
>> convert :: String -> [Int]
>> convert = map read . words
>>
>> read :: FilePath -> IO [[Int]]
>> read fp = (map convert . lines) `fmap` readFile fp
>>
>>
> If a single list of Ints is OK, the code can be much simpler:
>
>  read' :: FilePath -> IO [Int]
>> read' fp = (map read . words) `fmap` readFile fp
>>
>
>
> --
> Met vriendelijke groet,
> Henk-Jan van Tuyl
>
>
> --
> http://functor.bamikanarie.com
> http://Van.Tuyl.eu/
> --
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>



-- 
Rafael Gustavo da Cunha Pereira Pinto
Electronic Engineer, MSc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20080721/cd21faf7/attachment.htm


More information about the Beginners mailing list