-
Notifications
You must be signed in to change notification settings - Fork 89
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
Alias Text and String to be the same #136
Comments
Since |
This issue's in response to a correspondence with Snoyman:
It's still debatable. It may be that we should change all Fay's text functions (well, it doesn't have any… I'm really talking about libraries like the DOM or jQuery) to work on a packed Text type and not String. That way we keep the familiar name, Text and have slightly more efficient strings. Thoughts, everyone? I could go either way on this, I think. |
I think using We should transparently replace |
Indeed, it has the same code sharing benefits. Also functions like |
Sorry I'm coming late to this party. I like the idea of |
So I've started approaching the concept of The next step is what confuses me. I discussed this a bit with @ajnsit, and for our purposes, I believe we just need three new exports from When using GHC, these three imports should just be I'm uncertain of how to proceed about implementing this, however. I was thinking about creating two separate modules, one for GHC compilation, and one for Fay usage (I started playing around with this approach in our local codebase), but I'm not really sure how to proceed about implementing it. Any advice/suggestions would be appreciated. |
I did a demo implementation in branch
|
Thank you, I'll have a look at that in more depth tomorrow to see how far I can take it. For comparison, I implemented basically what I needed for my current project in |
My understanding is that String is currently defined as a list internally Michael, I agree that you basically want two implementations of Text; the GHC has a flag to do the CPP processing, so it's actually not hard... but On Sun, Jan 6, 2013 at 9:44 AM, Michael Snoyman notifications@github.comwrote:
|
Afaik |
If you look at the yesod-fay code I referenced, I actually implemented a minimal subset of CPP necessary in order to switch between Fay and GHC code. It's not beautiful, but I think it's sufficient for our purposes here. Any objection if I end up using something like that in my implementation? We could also consider using cpphs, but (1) I think it's a bit overkill, and (2) the licensing scares me. |
I think in general platforms will have a |
But do we really want to have to spin off a separate process each and every time we compile a file? Basic support for Additionally, I wouldn't want to unnecessarily tie ourselves to specific run environments. Wasn't there a proof-of-concept Fay-compiled-to-JS-via-GHCJS? Such a technique couldn't be implemented if we depended on |
@bergmark Yes, I think using my CPP code will be fastest to getting started. IANAL, but LGPL does worry me (though cpphs also has some custom license as well). But it doesn't really matter: if cpphs is viral, then fay is already infected: http://packdeps.haskellers.com/licenses/fay |
Somebody claiming to be Michael Snoyman wrote:
IANAL, but the LGPL is not going to "viral" you for exec'ing it. Even the Stephen Paul Weber, @singpolyma |
I link against fay, and therefore against cpphs. |
Yep, and that's via haskell-src-exts, which is not going to go away. Makes me wonder, though... does haskell-src-exts already support CPP? On Mon, Jan 7, 2013 at 7:45 AM, Michael Snoyman notifications@github.comwrote:
|
And the answer: no, it's just used for unlit currently. On Mon, Jan 7, 2013 at 8:33 AM, Chris Smith cdsmith@gmail.com wrote:
|
I'm starting work on When building for the client, you would use I don't quite see where the CPP enters into it. |
Well, CPP was there as a way to get Fay and Haskell code to build using the On Mon, Jan 7, 2013 at 1:15 PM, Chris Done notifications@github.com wrote:
|
Should be possible to do this now! I guess we can just have an opaque type Text around js strings, or is there still a need to alias this with String? Seems reasonable to me to provide separate implementations since that's what Haskell does. |
I definitely agree with keeping them separate, and providing an API for
|
Here's a very nice solution for this! #321 |
Related to this I'll try to (finally) release |
@bergmark This looks like good stuff, I'm happy to see this package come into existence! |
When sharing datatypes between the server and client, I'm forced to use String instead of Text (there are likely a few other examples of this too). It would be nice if Fay could automatically treat Text as a synonym for String, while for the server-side code use Data.Text.Text.
The text was updated successfully, but these errors were encountered: