Re: [Haskell-cafe] Data.List / Map: simple serialization?

2011-06-10 Thread Dmitri O.Kondratiev
On Thu, Jun 9, 2011 at 11:31 AM, Max Bolingbroke batterseapo...@hotmail.com wrote: If you want plain text serialization, writeFile output.txt . show and fmap read (readFile output.txt) should suffice... Max This code works: main = do let xss = [[1,2,3],[4,5,6],[7,8],[9]]

Re: [Haskell-cafe] Data.List / Map: simple serialization?

2011-06-10 Thread Daniel Fischer
On Friday 10 June 2011, 13:49:23, Dmitri O.Kondratiev wrote: On Thu, Jun 9, 2011 at 11:31 AM, Max Bolingbroke batterseapo...@hotmail.com wrote: If you want plain text serialization, writeFile output.txt . show and fmap read (readFile output.txt) should suffice... Max This code

Re: [Haskell-cafe] Data.List / Map: simple serialization?

2011-06-10 Thread Dmitri O.Kondratiev
On Fri, Jun 10, 2011 at 4:13 PM, Daniel Fischer daniel.is.fisc...@googlemail.com wrote: On Friday 10 June 2011, 13:49:23, Dmitri O.Kondratiev wrote: On Thu, Jun 9, 2011 at 11:31 AM, Max Bolingbroke batterseapo...@hotmail.com wrote: If you want plain text serialization, writeFile

Re: [Haskell-cafe] Data.List / Map: simple serialization?

2011-06-10 Thread Ketil Malde
Dmitri O.Kondratiev doko...@gmail.com writes: xss2 - read `fmap` readFile output.txt Two questions: 1) Why to use 'fmap' at all if a complete file is read in a single line of text? Because it's not 'map', it's more generalized. So the argument ('read' here) is applied to whatever is

Re: [Haskell-cafe] Data.List / Map: simple serialization?

2011-06-10 Thread Daniel Fischer
On Friday 10 June 2011, 14:25:59, Dmitri O.Kondratiev wrote: Two questions: 1) Why to use 'fmap' at all if a complete file is read in a single line of text? Well, it's a matter of taste whether to write foo - fmap read (readFile bar) stuffWithFoo or text - readFile bar let

Re: [Haskell-cafe] Data.List / Map: simple serialization?

2011-06-10 Thread Dmitri O.Kondratiev
Thanks for the excellent explanation! : On Fri, Jun 10, 2011 at 4:49 PM, Daniel Fischer daniel.is.fisc...@googlemail.com wrote: On Friday 10 June 2011, 14:25:59, Dmitri O.Kondratiev wrote: Two questions: 1) Why to use 'fmap' at all if a complete file is read in a single line of text?

[Haskell-cafe] Data.List / Map: simple serialization?

2011-06-09 Thread Dmitri O.Kondratiev
Hello, Please advise on existing serialization libraries. I need a simple way to serialize Data.List and Data.Map to plain text files. Thanks, Dmitri ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Data.List / Map: simple serialization?

2011-06-09 Thread Ivan Lazar Miljenovic
On 9 June 2011 17:23, Dmitri O.Kondratiev doko...@gmail.com wrote: Hello, Please advise on existing serialization libraries. I need a simple way to serialize Data.List and Data.Map  to plain text files. Well, the obvious solution is to just use show and read... though if you want something

Re: [Haskell-cafe] Data.List / Map: simple serialization?

2011-06-09 Thread Max Bolingbroke
If you want plain text serialization, writeFile output.txt . show and fmap read (readFile output.txt) should suffice... Max On 9 June 2011 08:23, Dmitri O.Kondratiev doko...@gmail.com wrote: Hello, Please advise on existing serialization libraries. I need a simple way to serialize Data.List

Re: [Haskell-cafe] Data.List / Map: simple serialization?

2011-06-09 Thread Yves Parès
Binary should be pretty easy to use (and more advisable if you need performance), since it defines the Binary instance for every basic type, including of course Map. I don't know about cereal, but I suppose it will be pretty much the same. The major difference is that binary offers lazy

Re: [Haskell-cafe] Data.List / Map: simple serialization?

2011-06-09 Thread Dmitri O.Kondratiev
On Thu, Jun 9, 2011 at 11:31 AM, Max Bolingbroke batterseapo...@hotmail.com wrote: If you want plain text serialization, writeFile output.txt . show and fmap read (readFile output.txt) should suffice... Max This is really a simple way that I like, thanks. Do I understand this right, that

Re: [Haskell-cafe] Data.List / Map: simple serialization?

2011-06-09 Thread Max Bolingbroke
Hi Dmitri, On 9 June 2011 09:13, Dmitri O.Kondratiev doko...@gmail.com wrote: I wonder how Haskell will distribute memory between the buffer for sequential element access (list elements, map tree nodes) and memory for computation while reading in list, Data.Map from file? Your list only has

Re: [Haskell-cafe] Data.List / Map: simple serialization?

2011-06-09 Thread Dmitri O.Kondratiev
On Thu, Jun 9, 2011 at 7:23 PM, Max Bolingbroke batterseapo...@hotmail.comwrote: Hi Dmitri, On 9 June 2011 09:13, Dmitri O.Kondratiev doko...@gmail.com wrote: I wonder how Haskell will distribute memory between the buffer for sequential element access (list elements, map tree nodes) and