<div dir="ltr">mark, have you seen ghcjs? It uses the ghc pass hooks to provide a JS targeting backend for full GHC haskell.<div>I imagine you could reuse some of that work to cook up GHC backends for other systems like JVM too!</div>

<div><br></div><div>NB: depending on the target, you may want to take over from GHC after core or after CMM, depending on the system in mind.<a href="https://github.com/ghcjs/ghcjs">https://github.com/ghcjs/ghcjs</a></div>

</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 13, 2014 at 4:15 PM, Marc Weber <span dir="ltr"><<a href="mailto:marco-oweber@gmx.de" target="_blank">marco-oweber@gmx.de</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I love Haskell, and it gets many things right.<br>
However eg its hard to target JS in an efficient way.<br>
Sometimes I just need a quick and dirty (somewhat typesafe)<br>
program which gets the job done - sometimes its js, sometimes a tool in<br>
console, sometimse web/client code (also smartphone applets).<br>
<br>
<a href="http://haxe.org" target="_blank">haxe.org</a> comes close, but while the language is fun to use it still has<br>
some shortcomings - and sometimes I hit unexpected bugs.<br>
<br>
The real question I have is:<br>
- Haskell is cool<br>
- being lazy is cool<br>
- having OO is cool (because you can target Java/Flash/.. easily)<br>
- how to get best of all worlds?<br>
<br>
So I think about creating my own language is should look like more like<br>
a source code generator than language which contains different sub<br>
universes. The idea is to code some parts - such as a parser - in a<br>
Haskell like dialect, then reuse it in quick and dirty OO world (Java<br>
like).<br>
<br>
Of course additional targets could be just plain old C, because C++ is<br>
known to be very complex - and there are tons of legacy code which<br>
should be maintained (such as Vim) - but there is no true upstream,<br>
because coding C takes so much more time.<br>
I also just don't get why it should not be possible to write code once<br>
(such as parsing snippets or highlighting), then reuse it for Vim,<br>
Emacs, Yi, ..<br>
There is no way, you cannot merge such editors - but eventually there is<br>
a way to "code once" and compile down to elisp, C, Haskell ...<br>
Live is too short to duplicate much work ..<br>
<br>
I'm writing to this mailinglist because the knowledge in the Haskell<br>
community is incredible - and I want to know<br>
<br>
* who would join such an effort (maybe write drafts, get funded by<br>
  kickstarter)<br>
<br>
* does such attempt already exist ?<br>
<br>
Languages like <a href="http://impredicative.com/ur" target="_blank">impredicative.com/ur</a>, Haskell, lisp, Java, Haxe cleary also illustrate<br>
the power of "meta programming" or "source code generation at compile<br>
time", yet they all come with their own limitations, eg ur cannot create<br>
generate code which is useful outside of a web server and so on.<br>
So I feel I'm reinventing the wheel again and again - I'd like to stop<br>
this.<br>
<br>
So the goal would be trying to write "functors/code" which you can<br>
instantiate with different memeory management models, tell to target<br>
different backends etc.<br>
<br>
I love Haskell, its community and what it achieved, but somehow I feel<br>
that its only 80% of the true story getting everything done.<br>
<br>
Eg haxe already allows me to write code like such - and then compile it<br>
twice: once to create a .js file, once to create server side<br>
js/php/neko/whatsoever.<br>
<br>
  class FormComponentGeoLocation {<br>
   new (opts){<br>
    this.opts = opts;<br>
   }<br>
<br>
  function check(value){<br>
    // check with regular expression that value has lat lon numbers<br>
  }<br>
<br>
  #if SERVER<br>
    function assignValuesFromInputs(post_data, values){<br>
     var value = post_data[<a href="http://opts.name" target="_blank">opts.name</a>];<br>
     check(value);<br>
     values[<a href="http://opts.name" target="_blank">opts.name</a>] = post_data[<a href="http://opts.name" target="_blank">opts.name</a>];<br>
    }<br>
  #end<br>
<br>
  #if js<br>
    additional client code<br>
    eg use geo location apis to fill in lat/lon<br>
<br>
    function assignValuesFromInputs(values);<br>
       var value = post_data[<a href="http://opts.name" target="_blank">opts.name</a>];<br>
       check(value);<br>
       values[<a href="http://opts.name" target="_blank">opts.name</a>] = value;<br>
     }<br>
  #end<br>
<br>
  }<br>
<br>
So this is what I'd call modular code I can reuse which has all logic it<br>
needs.<br>
<br>
While Haskell is great I'm unsure wether it allows me to create modules<br>
by code (I know about template haskell, but that's only about adding<br>
code) - and while being lazy is a feature sometimes I'd like to be<br>
strict. (I know that people work on simplifying this)<br>
<br>
ideas/thougts/links/you'd like to join understanding whether such a<br>
goal would be reachable at all?<br>
<span class="HOEnZb"><font color="#888888"><br>
Marc Weber<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</font></span></blockquote></div><br></div>