Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-05 Thread Dmitry Vyal

On 09/04/2013 05:39 PM, Adam Bergmark wrote:
Here are some points I'd like to emphasize in addition to the threads 
above, with the disclaimer that I'm the maintainer of Fay.


Fay tries to be very simple, the code base is small (~4800 LoC). This 
really lowers the entry barrier for contributions which I think is 
very important for open source projects. GHCJS is much more 
complicated since it tries to do so much. For GHCJS I'd be afraid that 
the developers might eventually abandon the project and then it'd be 
pretty hard to take over development. Much easier for someone to take 
over Fay development. I think you can safely expect to find bugs in 
all compilers, and if you do and you are in a hurry you might have to 
fix it yourself. Fay has very simple output that is close to both 
Haskell and JavaScript so it's pretty easy to just add a breakpoint 
and start debugging.


Even if GHCJS can successfully compile most of hackage, would we want 
to have these as dependencies in web projects? An output size of 1MiB 
is nothing when compiling a binary, but for a public website 1MiB can 
still be quite a lot, add some transitive dependencies and output will 
explode. Most people don't optimize their packages to have few 
dependencies, which makes sense since the abstraction usually heavily 
outweighs code size. So either way you would probably want to write 
some specific light-weight versions of libraries you want to use, 
that's one reason both GHCJS and Fay have their own base packages.


One place I think GHCJS can shine is for non standard web applications 
such as WEBGL games. Nothing stopping you from using Fay for this, but 
I expect you can really start to leverage GHCJS's threaded runtime here.




Hi Adam!

We found it to be very convenient to use both Hastec and Fay. Since the 
former (as well, as GHCJS) is based on GHC, you can be quite sure any 
bugs you encounter are yours, not of the compiler. And after your code 
works with Hastec and so your idea is tested, you can try to port it to 
Fay. Usually it's trivial, but prepare to encounter some minor compiler 
deficiencies here and there.


So my proposal to original poster would be to tell a bit about both. 
After all, they represent different approaches to JS generation each 
with it's own pros and cons.


Regards,
Dmitry

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Niklas Hambüchen
Hi, I'm also interested in that.

Have you already evaluated haste?

It does not seem to have any of your cons, but maybe others.

What I particularly miss from all solutions is the ability to simply 
call parts written in Haskell from Javascript, e.g. to write `fib` and 
then integrate it into an existing Javascript application (they are all 
more interested in doing the other direction).

On Wed 04 Sep 2013 17:14:55 JST, Alejandro Serrano Mena wrote:
 Hi,
 I'm currently writing a tutorial on web applications using Haskell. I
 know the pros and cons of each server-side library (Yesod, Snap,
 Scotty, Warp, Happstack), but I'm looking for the right choice for
 client-side programming that converts Haskell to JavaScript. I've
 finally come to Fay vs. GHCJS, and would like your opinion on what's
 the best to tackle. My current list of pros and cons is:

 Fay
 ===
 Pros:
 - Does not need GHC 7.8
 - Easy FFI with JS
 - Has libraries for integration with Yesod and Snap

 Cons:
 - Only supports a subset of GHC (in particular, no type classes)


 GHCJS
 ==
 Pros:
 - Supports full GHC
 - Easy FFI with JS
 - Highly opinionated point: will stay longer than Fay (but it's very
 important for not having a tutorial that is old in few months)

 Cons:
 - Needs GHC 7.8 (but provides a Vagrant image)


 ___
 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


Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Alejandro Serrano Mena
I haven't looked at Haste too much, I'll give it a try.

My main problem is that I would like to find a solution that will continue
working in years (somehow, that will became the solution for generating
JS from Haskell code). That's why I see GHCJS (which just includes some
patches to mainstream GHC) as the preferred solution, because it seems the
most probable to continue working when new versions of GHC appear.


2013/9/4 Niklas Hambüchen m...@nh2.me

 Hi, I'm also interested in that.

 Have you already evaluated haste?

 It does not seem to have any of your cons, but maybe others.

 What I particularly miss from all solutions is the ability to simply
 call parts written in Haskell from Javascript, e.g. to write `fib` and
 then integrate it into an existing Javascript application (they are all
 more interested in doing the other direction).

 On Wed 04 Sep 2013 17:14:55 JST, Alejandro Serrano Mena wrote:
  Hi,
  I'm currently writing a tutorial on web applications using Haskell. I
  know the pros and cons of each server-side library (Yesod, Snap,
  Scotty, Warp, Happstack), but I'm looking for the right choice for
  client-side programming that converts Haskell to JavaScript. I've
  finally come to Fay vs. GHCJS, and would like your opinion on what's
  the best to tackle. My current list of pros and cons is:
 
  Fay
  ===
  Pros:
  - Does not need GHC 7.8
  - Easy FFI with JS
  - Has libraries for integration with Yesod and Snap
 
  Cons:
  - Only supports a subset of GHC (in particular, no type classes)
 
 
  GHCJS
  ==
  Pros:
  - Supports full GHC
  - Easy FFI with JS
  - Highly opinionated point: will stay longer than Fay (but it's very
  important for not having a tutorial that is old in few months)
 
  Cons:
  - Needs GHC 7.8 (but provides a Vagrant image)
 
 
  ___
  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


Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Nathan Hüsken
In my opinion haste is somewhere between Fay and ghcjs. It supports more 
than Fay, but in difference to ghcjs some PrimOps are not supported 
(weak pointers for example).


It is a little bit more direct than ghcjs, in the sense that it does 
not need such a big rts written in js.


I like haste :).

What I wonder is how the outputs of these 3 compilers compare speed wise.

On 09/04/2013 11:11 AM, Alejandro Serrano Mena wrote:

I haven't looked at Haste too much, I'll give it a try.

My main problem is that I would like to find a solution that will 
continue working in years (somehow, that will became the solution 
for generating JS from Haskell code). That's why I see GHCJS (which 
just includes some patches to mainstream GHC) as the preferred 
solution, because it seems the most probable to continue working when 
new versions of GHC appear.



2013/9/4 Niklas Hambüchen m...@nh2.me mailto:m...@nh2.me

Hi, I'm also interested in that.

Have you already evaluated haste?

It does not seem to have any of your cons, but maybe others.

What I particularly miss from all solutions is the ability to simply
call parts written in Haskell from Javascript, e.g. to write `fib` and
then integrate it into an existing Javascript application (they
are all
more interested in doing the other direction).

On Wed 04 Sep 2013 17:14:55 JST, Alejandro Serrano Mena wrote:
 Hi,
 I'm currently writing a tutorial on web applications using
Haskell. I
 know the pros and cons of each server-side library (Yesod, Snap,
 Scotty, Warp, Happstack), but I'm looking for the right choice for
 client-side programming that converts Haskell to JavaScript. I've
 finally come to Fay vs. GHCJS, and would like your opinion on what's
 the best to tackle. My current list of pros and cons is:

 Fay
 ===
 Pros:
 - Does not need GHC 7.8
 - Easy FFI with JS
 - Has libraries for integration with Yesod and Snap

 Cons:
 - Only supports a subset of GHC (in particular, no type classes)


 GHCJS
 ==
 Pros:
 - Supports full GHC
 - Easy FFI with JS
 - Highly opinionated point: will stay longer than Fay (but it's very
 important for not having a tutorial that is old in few months)

 Cons:
 - Needs GHC 7.8 (but provides a Vagrant image)


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org mailto: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


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Adam Bergmark
You might be interested in these two comment threads (and maybe the rest of
the comments as well):
http://www.reddit.com/r/haskell/comments/1ldqav/thoughts_on_uhc_vs_haste_vs_fay/cbyrhwz
http://www.reddit.com/r/haskell/comments/1htqi2/announce_haste_the_haskell_to_js_compiler_is_now/cay79g9?context=1



On Wed, Sep 4, 2013 at 12:36 PM, Nathan Hüsken nathan.hues...@posteo.dewrote:

  In my opinion haste is somewhere between Fay and ghcjs. It supports more
 than Fay, but in difference to ghcjs some PrimOps are not supported (weak
 pointers for example).

 It is a little bit more direct than ghcjs, in the sense that it does not
 need such a big rts written in js.

 I like haste :).

 What I wonder is how the outputs of these 3 compilers compare speed wise.


 On 09/04/2013 11:11 AM, Alejandro Serrano Mena wrote:

 I haven't looked at Haste too much, I'll give it a try.

  My main problem is that I would like to find a solution that will
 continue working in years (somehow, that will became the solution for
 generating JS from Haskell code). That's why I see GHCJS (which just
 includes some patches to mainstream GHC) as the preferred solution, because
 it seems the most probable to continue working when new versions of GHC
 appear.


 2013/9/4 Niklas Hambüchen m...@nh2.me

 Hi, I'm also interested in that.

 Have you already evaluated haste?

 It does not seem to have any of your cons, but maybe others.

 What I particularly miss from all solutions is the ability to simply
 call parts written in Haskell from Javascript, e.g. to write `fib` and
 then integrate it into an existing Javascript application (they are all
 more interested in doing the other direction).

 On Wed 04 Sep 2013 17:14:55 JST, Alejandro Serrano Mena wrote:
  Hi,
  I'm currently writing a tutorial on web applications using Haskell. I
  know the pros and cons of each server-side library (Yesod, Snap,
  Scotty, Warp, Happstack), but I'm looking for the right choice for
  client-side programming that converts Haskell to JavaScript. I've
  finally come to Fay vs. GHCJS, and would like your opinion on what's
  the best to tackle. My current list of pros and cons is:
 
  Fay
  ===
  Pros:
  - Does not need GHC 7.8
  - Easy FFI with JS
  - Has libraries for integration with Yesod and Snap
 
  Cons:
  - Only supports a subset of GHC (in particular, no type classes)
 
 
  GHCJS
  ==
  Pros:
  - Supports full GHC
  - Easy FFI with JS
  - Highly opinionated point: will stay longer than Fay (but it's very
  important for not having a tutorial that is old in few months)
 
  Cons:
  - Needs GHC 7.8 (but provides a Vagrant image)
 
 
   ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe




 ___
 Haskell-Cafe mailing 
 listHaskell-Cafe@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe



 ___
 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


Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Joachim Breitner
Hi,

Am Mittwoch, den 04.09.2013, 14:46 +0200 schrieb Adam Bergmark:
 You might be interested in these two comment threads (and maybe the
 rest of the comments as well):
 http://www.reddit.com/r/haskell/comments/1ldqav/thoughts_on_uhc_vs_haste_vs_fay/cbyrhwz
 http://www.reddit.com/r/haskell/comments/1htqi2/announce_haste_the_haskell_to_js_compiler_is_now/cay79g9?context=1

and another data point:
http://www.joachim-breitner.de/blog/archives/602-Running-Circle-Packing-in-the-Browser-using-Haste.html

Greetings,
Joachim


-- 
Joachim “nomeata” Breitner
  m...@joachim-breitner.de • http://www.joachim-breitner.de/
  Jabber: nome...@joachim-breitner.de  • GPG-Key: 0x4743206C
  Debian Developer: nome...@debian.org


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Daniil Frumin
Hi!

On Sep 4, 2013, at 13:02, Niklas Hambüchen m...@nh2.me wrote:

 Hi, I'm also interested in that.

 Have you already evaluated haste?

 It does not seem to have any of your cons, but maybe others.

 What I particularly miss from all solutions is the ability to simply
 call parts written in Haskell from Javascript, e.g. to write `fib` and
 then integrate it into an existing Javascript application (they are all
 more interested in doing the other direction).


So, I don't how Fay handles things but I can say the following about GHCJS:

I have to admit that it's not that easy to call Haskell from
JavaScript as I want it.
However, there are several functions you can use for doing that. GHCJS
supports running actions in main asynchronous threads (application
is considered to be terminated when the thread is finished), regular
asynchronous threads and synchronous threads. Since you want to call
pure Haskell code you probably want to use runSync.

One way to do that would be to use an intermediate object to store the
result of calling Fib:


fib :: Int - Int
fib n = fibs !! n
  where fibs = 0:1:zipWith (+) fibs (tail fibs)

fibAction :: JSRef () - Int - IO ()
fibAction ref n = do
res - toJSRef (fib n)
setProp (result::Text) res ref

function go() {
   var i = parseInt($(#num).val(), 10);
   var o = { result : null };
   var oref = mkJSRefNew(o);
   var act = h$c3( h$ap2_e
 , h$mainZCMainzifibAction
 , oref
 , i );
   h$runSync(act);
   $(#result).text(o.result);
};


You can find the complete sourcecode and a runnable executable here:
http://co-dan.github.io/ghcjs/examples/Fib.hs 
http://co-dan.github.io/ghcjs/examples/Fib/index.html


I think it's nice that you've raised that question, I will think about
implementing a finer API for calling Haskell from JS.

NB: It also sounds like you might benefit from the non-concurrent
GHCJS runtime and codegen that Luite is now porting to the new API.
Since you plan to implement your interface/interactions in JS you
probably don't need support for concurrency and you can enjoy smaller
code  rts sizes.

 On Wed 04 Sep 2013 17:14:55 JST, Alejandro Serrano Mena wrote:
 Hi,
 I'm currently writing a tutorial on web applications using Haskell. I
 know the pros and cons of each server-side library (Yesod, Snap,
 Scotty, Warp, Happstack), but I'm looking for the right choice for
 client-side programming that converts Haskell to JavaScript. I've
 finally come to Fay vs. GHCJS, and would like your opinion on what's
 the best to tackle. My current list of pros and cons is:

 Fay
 ===
 Pros:
 - Does not need GHC 7.8
 - Easy FFI with JS
 - Has libraries for integration with Yesod and Snap

 Cons:
 - Only supports a subset of GHC (in particular, no type classes)


 GHCJS
 ==
 Pros:
 - Supports full GHC
 - Easy FFI with JS
 - Highly opinionated point: will stay longer than Fay (but it's very
 important for not having a tutorial that is old in few months)

 Cons:
 - Needs GHC 7.8 (but provides a Vagrant image)


 ___
 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

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Adam Bergmark
Here are some points I'd like to emphasize in addition to the threads
above, with the disclaimer that I'm the maintainer of Fay.

Fay tries to be very simple, the code base is small (~4800 LoC). This
really lowers the entry barrier for contributions which I think is very
important for open source projects. GHCJS is much more complicated since it
tries to do so much. For GHCJS I'd be afraid that the developers might
eventually abandon the project and then it'd be pretty hard to take over
development. Much easier for someone to take over Fay development. I think
you can safely expect to find bugs in all compilers, and if you do and you
are in a hurry you might have to fix it yourself. Fay has very simple
output that is close to both Haskell and JavaScript so it's pretty easy to
just add a breakpoint and start debugging.

Even if GHCJS can successfully compile most of hackage, would we want to
have these as dependencies in web projects? An output size of 1MiB is
nothing when compiling a binary, but for a public website 1MiB can still be
quite a lot, add some transitive dependencies and output will explode. Most
people don't optimize their packages to have few dependencies, which makes
sense since the abstraction usually heavily outweighs code size. So either
way you would probably want to write some specific light-weight versions of
libraries you want to use, that's one reason both GHCJS and Fay have their
own base packages.

One place I think GHCJS can shine is for non standard web applications such
as WEBGL games. Nothing stopping you from using Fay for this, but I expect
you can really start to leverage GHCJS's threaded runtime here.

I'm not sure if GHCJS or Haste have any out of the box solutions for doing
client-server communication. In Fay you can just serialize any data type
automatically on the front and backend to a json format and then
deserialize it automatically again on the other end. You can also leverage
phantom types (
https://github.com/fpco/yesod-fay/blob/master/Language/Fay/Yesod.hs#L41) to
typecheck this communication.

It's hard to know how well GHCJS performs in a real web application. FP
Complete uses Fay for their IDE and School of Haskell so it has been battle
tested, so if you want something that definitely works today I think Fay is
the more reliable option.

It is possible that GHCJS will eventually supercede Fay. But if you want
something that's easy to use today you can always write Fay, and then
convert it to GHCJS later since Fay is a subset of Haskell.

I think GHCJS needs more time to prove itself. I know the developers are
hard at work and I hope they will focus on a lot of learning materials.
Once you can `cabal install ghcjs` and just get started I think they will
see a lot more interest coming their way.

Let me know if you have more questions. If you decide to use Fay in your
tutorial I'd be happy to help out, just send me an e-mail!

- Adam



On Wed, Sep 4, 2013 at 2:46 PM, Adam Bergmark a...@edea.se wrote:

 You might be interested in these two comment threads (and maybe the rest
 of the comments as well):

 http://www.reddit.com/r/haskell/comments/1ldqav/thoughts_on_uhc_vs_haste_vs_fay/cbyrhwz

 http://www.reddit.com/r/haskell/comments/1htqi2/announce_haste_the_haskell_to_js_compiler_is_now/cay79g9?context=1



 On Wed, Sep 4, 2013 at 12:36 PM, Nathan Hüsken 
 nathan.hues...@posteo.dewrote:

  In my opinion haste is somewhere between Fay and ghcjs. It supports
 more than Fay, but in difference to ghcjs some PrimOps are not supported
 (weak pointers for example).

 It is a little bit more direct than ghcjs, in the sense that it does
 not need such a big rts written in js.

 I like haste :).

 What I wonder is how the outputs of these 3 compilers compare speed wise.


 On 09/04/2013 11:11 AM, Alejandro Serrano Mena wrote:

 I haven't looked at Haste too much, I'll give it a try.

  My main problem is that I would like to find a solution that will
 continue working in years (somehow, that will became the solution for
 generating JS from Haskell code). That's why I see GHCJS (which just
 includes some patches to mainstream GHC) as the preferred solution, because
 it seems the most probable to continue working when new versions of GHC
 appear.


 2013/9/4 Niklas Hambüchen m...@nh2.me

 Hi, I'm also interested in that.

 Have you already evaluated haste?

 It does not seem to have any of your cons, but maybe others.

 What I particularly miss from all solutions is the ability to simply
 call parts written in Haskell from Javascript, e.g. to write `fib` and
 then integrate it into an existing Javascript application (they are all
 more interested in doing the other direction).

 On Wed 04 Sep 2013 17:14:55 JST, Alejandro Serrano Mena wrote:
  Hi,
  I'm currently writing a tutorial on web applications using Haskell. I
  know the pros and cons of each server-side library (Yesod, Snap,
  Scotty, Warp, Happstack), but I'm looking for the right choice for
  client-side 

Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Luite Stegeman
On Wed, Sep 4, 2013 at 6:32 PM, Daniil Frumin difru...@gmail.com wrote:



 I think it's nice that you've raised that question, I will think about
 implementing a finer API for calling Haskell from JS.


It sounds like something like h$runSyncWithResult (name open for
bikeshedding) that takes an IO (JSRef a) and returns the result to the
caller, or null (exception?) when the synchronous thread terminated for
some reason, would fit the bill. I think this can be implemented in a few
lines of JS.

the current API is a bit bare-bones, based around calling main or a few
other top-level IO actions and doing the rest from Haskell code. The
Haskell code can make callbacks (JS functions that run Haskell when called,
see [1] ), but that can be a bit cumbersome to use when wrapping a library
with lots of external JavaScript.

If anyone has ideas of how they'd like a call-Haskell-functions-from-JS API
to look, I'd be happy to hear and see if we can make something nice.

One thing to keep in mind though is that type information has been erased
from the compiled code, making a generic applyHaskellFun(fun,x,y) that
would run 'fun x y' and return its result would be rather risky. That's why
the syncCallback/asyncCallback actions use JSRef, letting the Haskell side
do the conversion. Going through 'foreign export' could work though, or
perhaps there are other options that make this safer.

luite
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Chris Smith
I second the recommendation to look at Haste.  It's what I would pick for a
project like this today.

In the big picture, Haste and GHCJS are fairly similar.  But when it comes
to the ugly details of the runtime system, GHCJS adopts the perspective
that it's basically an emulator, where compatibility is the number one
goal.  Haste goes for a more native approach; while the evaluation
semantics and such are completely faithful to Haskell, it doesn't go out of
the way to emulate the gritty details of GHC's runtime system.
On Sep 4, 2013 3:38 AM, Nathan Hüsken nathan.hues...@posteo.de wrote:

  In my opinion haste is somewhere between Fay and ghcjs. It supports more
 than Fay, but in difference to ghcjs some PrimOps are not supported (weak
 pointers for example).

 It is a little bit more direct than ghcjs, in the sense that it does not
 need such a big rts written in js.

 I like haste :).

 What I wonder is how the outputs of these 3 compilers compare speed wise.

 On 09/04/2013 11:11 AM, Alejandro Serrano Mena wrote:

 I haven't looked at Haste too much, I'll give it a try.

  My main problem is that I would like to find a solution that will
 continue working in years (somehow, that will became the solution for
 generating JS from Haskell code). That's why I see GHCJS (which just
 includes some patches to mainstream GHC) as the preferred solution, because
 it seems the most probable to continue working when new versions of GHC
 appear.


 2013/9/4 Niklas Hambüchen m...@nh2.me

 Hi, I'm also interested in that.

 Have you already evaluated haste?

 It does not seem to have any of your cons, but maybe others.

 What I particularly miss from all solutions is the ability to simply
 call parts written in Haskell from Javascript, e.g. to write `fib` and
 then integrate it into an existing Javascript application (they are all
 more interested in doing the other direction).

 On Wed 04 Sep 2013 17:14:55 JST, Alejandro Serrano Mena wrote:
  Hi,
  I'm currently writing a tutorial on web applications using Haskell. I
  know the pros and cons of each server-side library (Yesod, Snap,
  Scotty, Warp, Happstack), but I'm looking for the right choice for
  client-side programming that converts Haskell to JavaScript. I've
  finally come to Fay vs. GHCJS, and would like your opinion on what's
  the best to tackle. My current list of pros and cons is:
 
  Fay
  ===
  Pros:
  - Does not need GHC 7.8
  - Easy FFI with JS
  - Has libraries for integration with Yesod and Snap
 
  Cons:
  - Only supports a subset of GHC (in particular, no type classes)
 
 
  GHCJS
  ==
  Pros:
  - Supports full GHC
  - Easy FFI with JS
  - Highly opinionated point: will stay longer than Fay (but it's very
  important for not having a tutorial that is old in few months)
 
  Cons:
  - Needs GHC 7.8 (but provides a Vagrant image)
 
 
   ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe




 ___
 Haskell-Cafe mailing 
 listHaskell-Cafe@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe



 ___
 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


Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Adam Bergmark
Niklas: I missed your note about calling Haskell from JS, see this for Fay:
https://github.com/faylang/fay/wiki/Fay-Status-Update-September-2013%3A-ZuriHac%2C-typeclasses%2C-haskell-suite%2C-and-strictness-wrappers#javascript-fay-communication



On Wed, Sep 4, 2013 at 8:18 PM, Luite Stegeman stege...@gmail.com wrote:


 On Wed, Sep 4, 2013 at 6:32 PM, Daniil Frumin difru...@gmail.com wrote:



 I think it's nice that you've raised that question, I will think about
 implementing a finer API for calling Haskell from JS.


 It sounds like something like h$runSyncWithResult (name open for
 bikeshedding) that takes an IO (JSRef a) and returns the result to the
 caller, or null (exception?) when the synchronous thread terminated for
 some reason, would fit the bill. I think this can be implemented in a few
 lines of JS.

 the current API is a bit bare-bones, based around calling main or a few
 other top-level IO actions and doing the rest from Haskell code. The
 Haskell code can make callbacks (JS functions that run Haskell when called,
 see [1] ), but that can be a bit cumbersome to use when wrapping a library
 with lots of external JavaScript.

 If anyone has ideas of how they'd like a call-Haskell-functions-from-JS
 API to look, I'd be happy to hear and see if we can make something nice.

 One thing to keep in mind though is that type information has been erased
 from the compiled code, making a generic applyHaskellFun(fun,x,y) that
 would run 'fun x y' and return its result would be rather risky. That's why
 the syncCallback/asyncCallback actions use JSRef, letting the Haskell side
 do the conversion. Going through 'foreign export' could work though, or
 perhaps there are other options that make this safer.

 luite

 ___
 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