Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a Vector datatype #255

Open
snoyberg opened this issue Mar 3, 2013 · 2 comments
Open

Provide a Vector datatype #255

snoyberg opened this issue Mar 3, 2013 · 2 comments
Labels

Comments

@snoyberg
Copy link
Contributor

snoyberg commented Mar 3, 2013

In our usage of Fay at FP Complete, we've significantly reduced the occurrences of serialization bugs by using Text in place of String. It also reduces the number of conversions the generated Javascript performs.

I wonder if we could do the same thing with lists and Vectors. A Vector could be represented in server-side code using Data.Vector.Vector, and as an array in generated Javascript. There could be toVector and fromVector helper functions, and serialization would essentially not touch Vector.

However, it also seems like this could be significantly more complicated than the work on Text, since the contained value in Text was always a character, whereas we have full polymorphism with Vectors.

Does this sound like something worth looking into?

@chrisdone
Copy link
Contributor

Hmm I think this would be fine to implement. Could just take the existing list implementation in the FFI and replace the representation (chains of Conses) with a native JS array, add the serialization in Convert (might have to change showToFay to use Data).

I presume any conversion bugs you have had are due to using Automatic and a polymorphically typed String? What is your implementation of Text?

@snoyberg
Copy link
Contributor Author

snoyberg commented Mar 3, 2013

One example of a bug we've run into a number of times is #250. We always have to make sure to wrap up our lists in some datatype. We have similar issues with Strings until we switched to Text.

We're using a very simplistic Text implementation provided by yesod-fay: https://github.com/fpco/yesod-fay/blob/master/Language/Fay/Yesod.hs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants