[Haskell-cafe] Any working example of using genericserialize?

Jason Dagit dagit at codersbase.com
Wed Sep 30 07:23:20 EDT 2009


On Wed, Sep 30, 2009 at 3:37 AM, Dimitry Golubovsky <golubovsky at gmail.com>wrote:

> Hi,
>
> I am trying to use the genericserialize package
> (http://hackage.haskell.org/package/genericserialize) but cannot get
> things working.
>
> While
> buildList (sexpSerialize [1, 2, 3])
>
> yields
>
> "(1 2 3)"
>
> as it might be expected, I cannot deserialize it back:
>
> *Main> (withList sexpDeserialize $ buildList (sexpSerialize [1, 2,
> 3])) :: Maybe [Integer]
> Nothing
>
> or
>
> *Main> (withList sexpDeserialize $ buildList (sexpSerialize [1, 2,
> 3])) :: Maybe [Int]
> Nothing
>
> while I would expect at least one of these cases result in Just [1, 2, 3]
>
> What am I missing?
>

I'm not sure.  I've never seen this library before, but I noticed this:
withList sexpDeserialize $ "12" :: Maybe Int
12
withList sexpDeserialize $ "(12)" :: Maybe [Int]
Just [12]

So it would seem that the sexpDeserialize is not handling the spaces in the
input.  But, I don't think that's the real problem, look at this:
withList sexpDeserialize $ "\"1 2 3\"" :: Maybe String
Just "1 2 3"

withList sexpDeserialize $ "(\"1 2 3\")" :: Maybe String
Nothing

withList sexpDeserialize $ "(\"1 2 3\")" :: Maybe [String]
Just ["1 2 3"]

So, it seems that the parens are making it into a list.

But, this fails also:
withList sexpDeserialize $ "(\"1\" \"2\" \"3\")" :: Maybe [String]
Nothing

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.

Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090930/898790cd/attachment.html


More information about the Haskell-Cafe mailing list