Re: [Haskell-cafe] Any generic serializer to String? was: Any working example of using genericserialize?

Hi,
On 9/30/09, Jason Dagit
Seems like using withList is wrong or the deserializer is simply buggy. It certainly doesn't work the way I would expect SExp reading to work. I also notice from reading the source on hackage that there may not be any tests for this package and it is a 0.1 release. I'd contact the author, as it seems there is a deficiency in the documentation or a bug in the implementation.
Thanks Jason for trying this. The genericserialize package is probably not finished yet. What else exists that could be used to serialize in generic way (i. e., anything that is an instance of Data and Typeable) into a string? It does not need to be very efficient as structures to be serialized are not huge (but may be pretty complex), and serialization is a part of an utility not to be used frequently. It only needs to "just work". One thing I thought of was to serialize to JSON (there is a generic serializer in one of packages although I did not test it other way) which has higher overhead than S-expressions though. Any other thoughts? Thanks. -- Dimitry Golubovsky Anywhere on the Web

FWIW, writing your own is not hard. I wrote a serializer for GHC using
Data in less than 150 (simple) LOC. It produces [Word8], but producing
strings instead would be easy. You can check out the code here:
http://darcs.haskell.org/ghc/compiler/utils/Serialized.hs
Cheers,
Max
2009/9/30 Dimitry Golubovsky
Hi,
On 9/30/09, Jason Dagit
wrote: [skip]
Seems like using withList is wrong or the deserializer is simply buggy. It certainly doesn't work the way I would expect SExp reading to work. I also notice from reading the source on hackage that there may not be any tests for this package and it is a 0.1 release. I'd contact the author, as it seems there is a deficiency in the documentation or a bug in the implementation.
Thanks Jason for trying this. The genericserialize package is probably not finished yet.
What else exists that could be used to serialize in generic way (i. e., anything that is an instance of Data and Typeable) into a string? It does not need to be very efficient as structures to be serialized are not huge (but may be pretty complex), and serialization is a part of an utility not to be used frequently. It only needs to "just work".
One thing I thought of was to serialize to JSON (there is a generic serializer in one of packages although I did not test it other way) which has higher overhead than S-expressions though.
Any other thoughts?
Thanks.
-- Dimitry Golubovsky
Anywhere on the Web _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hello Max, Wednesday, September 30, 2009, 5:53:37 PM, you wrote: afaik, SYB just provides gshow/gread functions what serialize any Data instance to String
FWIW, writing your own is not hard. I wrote a serializer for GHC using Data in less than 150 (simple) LOC. It produces [Word8], but producing strings instead would be easy. You can check out the code here:
Cheers, Max
2009/9/30 Dimitry Golubovsky
: Hi,
On 9/30/09, Jason Dagit
wrote: [skip]
Seems like using withList is wrong or the deserializer is simply buggy. It certainly doesn't work the way I would expect SExp reading to work. I also notice from reading the source on hackage that there may not be any tests for this package and it is a 0.1 release. I'd contact the author, as it seems there is a deficiency in the documentation or a bug in the implementation.
Thanks Jason for trying this. The genericserialize package is probably not finished yet.
What else exists that could be used to serialize in generic way (i. e., anything that is an instance of Data and Typeable) into a string? It does not need to be very efficient as structures to be serialized are not huge (but may be pretty complex), and serialization is a part of an utility not to be used frequently. It only needs to "just work".
One thing I thought of was to serialize to JSON (there is a generic serializer in one of packages although I did not test it other way) which has higher overhead than S-expressions though.
Any other thoughts?
Thanks.
-- Dimitry Golubovsky
Anywhere on the Web _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Bulat,
OK, gread/gshow seem to be like the basis primitives. If they work
properly, then it is what is needed.
Thanks.
On 9/30/09, Bulat Ziganshin
Hello Max,
Wednesday, September 30, 2009, 5:53:37 PM, you wrote:
afaik, SYB just provides gshow/gread functions what serialize any Data instance to String
FWIW, writing your own is not hard. I wrote a serializer for GHC using Data in less than 150 (simple) LOC. It produces [Word8], but producing strings instead would be easy. You can check out the code here:
Cheers, Max [skip] -- Dimitry Golubovsky
Anywhere on the Web

OK, I got it to work with gread/gshow.
However I have noticed this:
*Main> (gread $ gshow $ FuncExpr 0 [] (EmptyStmt 0)) :: [(Expression
Int, String)]
[(FuncExpr 0 [] (EmptyStmt 0),"")]
vs.
*Main> (gread $ gshow $ FuncExpr () [] (EmptyStmt ())) :: [(Expression
(), String)]
[]
Or even narrower:
*Main> (gread $ gshow 1)::[(Int, String)]
[(1,"")]
vs.
*Main> (gread $ gshow ())::[((), String)]
[]
that is, the unit type does not work well with gread/gshow, likely
because inner parentheses are not parsed as a constructor.
*Main> gshow ()
"(())"
Is this a known bug?
Thanks.
On Wed, Sep 30, 2009 at 10:19 AM, Dimitry Golubovsky
Bulat,
OK, gread/gshow seem to be like the basis primitives. If they work properly, then it is what is needed.
Thanks.
On 9/30/09, Bulat Ziganshin
wrote: Hello Max,
Wednesday, September 30, 2009, 5:53:37 PM, you wrote:
afaik, SYB just provides gshow/gread functions what serialize any Data instance to String
-- Dimitry Golubovsky Anywhere on the Web

Hi Dimitry,
On Thu, Oct 1, 2009 at 05:23, Dimitry Golubovsky
OK, I got it to work with gread/gshow.
However I have noticed this:
*Main> (gread $ gshow $ FuncExpr 0 [] (EmptyStmt 0)) :: [(Expression Int, String)] [(FuncExpr 0 [] (EmptyStmt 0),"")]
vs.
*Main> (gread $ gshow $ FuncExpr () [] (EmptyStmt ())) :: [(Expression (), String)] []
Or even narrower:
*Main> (gread $ gshow 1)::[(Int, String)] [(1,"")]
vs.
*Main> (gread $ gshow ())::[((), String)] []
that is, the unit type does not work well with gread/gshow, likely because inner parentheses are not parsed as a constructor.
*Main> gshow () "(())"
Is this a known bug?
I don't think this was noticed before. I wrote it down on the SYB tracker [1]. It should be fixed for the next release. Thanks, Pedro [1] http://code.google.com/p/scrapyourboilerplate/issues/detail?id=9
Thanks.
On Wed, Sep 30, 2009 at 10:19 AM, Dimitry Golubovsky
wrote: Bulat,
OK, gread/gshow seem to be like the basis primitives. If they work properly, then it is what is needed.
Thanks.
On 9/30/09, Bulat Ziganshin
wrote: Hello Max,
Wednesday, September 30, 2009, 5:53:37 PM, you wrote:
afaik, SYB just provides gshow/gread functions what serialize any Data instance to String
-- Dimitry Golubovsky
Anywhere on the Web _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (4)
-
Bulat Ziganshin
-
Dimitry Golubovsky
-
José Pedro Magalhães
-
Max Bolingbroke