News for hackers. Stuff that matters.
Re:GHCJS - Haskell in the Browser by sfvisser on Wednesday June 26, 2013 @12:09PM (#5946913)
Note that they have almost the entire runtime working, including the threading model, which allows you to fork threads, use MVars, perform STM, etc.

Truly awesome and very promising.

Re:GHCJS - Haskell in the Browser by wslh on Wednesday June 26, 2013 @12:15PM (#5946947)
Is incredible that we don't have an Android or iOS Haskell interpreter but we can run it on an embedded browser first.
Re:GHCJS - Haskell in the Browser by efnx on Wednesday June 26, 2013 @01:20PM (#5947458)
I hear ARM support will be standard in the next GHC, and there currently are ports and cross-compilers. Unless you're specifically talking about ghci, which I agree needs to be ported, though that hasn't happened for the browser yet. It's possible a project like this could help that happen, though...

http://hackage.haskell.org/trac/ghc/wiki/Building/CrossCompi... https://github.com/ghc-ios/ghc

Re:GHCJS - Haskell in the Browser by wslh on Wednesday June 26, 2013 @02:33PM (#5948027)
I am looking to the gchi because it's mainly to play and learn . I think a mobile/tablet is a nice environment to do that.
Re:GHCJS - Haskell in the Browser by joeyh on Wednesday June 26, 2013 @01:18PM (#5947443)
There are ports of ghc to both Android and IOS. I've run ghc directly on Android. ghci not so much, so you're technically right about there being no interpreter.
Re:GHCJS - Haskell in the Browser by geal on Wednesday June 26, 2013 @02:47PM (#5948129)
That's awesome! I have played a lot with Scala and Android, and type safety, options, futures really improved the development on Android (less code, less bugs). I would be curious to try Haskell on that platform.
Re:GHCJS - Haskell in the Browser by carterschonwald on Wednesday June 26, 2013 @12:12PM (#5946932)
Exactly! As I understand it, the moment js gets nice things like tail calls or concurrency, with very little work ghcjs can too! I'm really really excited.
Re:GHCJS - Haskell in the Browser by yoklov on Wednesday June 26, 2013 @12:43PM (#5947174)
Unfortunately, tail calls can't be implemented without breaking JS semantics. See: http://code.google.com/p/v8/issues/detail?id=457 .
Re:GHCJS - Haskell in the Browser by ethzero on Wednesday June 26, 2013 @02:13PM (#5947830)
You don't need tail calls in JavaScript in order have them in a language that compiles to JS. The tail call can be compiled as a while loop. This is what Scala does on the JVM (and presumably what Scala.js does as well).
Re:GHCJS - Haskell in the Browser by amalcon on Wednesday June 26, 2013 @02:51PM (#5948147)
This only works with calls that can be resolved at compile time (unless you mean a trampoline). That happens to be most of the common use, which is great, but it's not perfect.

Trampolines still work, albeit with a pretty substantial perf penalty.

Re:GHCJS - Haskell in the Browser by colanderman on Wednesday June 26, 2013 @04:02PM (#5948616)
No. Automatic tail call elimination can't be implemented without breaking JS semantics.

Manual tail calls can perfectly well be implemented without breaking anything.

Re:GHCJS - Haskell in the Browser by yoklov on Wednesday June 26, 2013 @10:49PM (#5950469)
Of course! The parent mentioned JS getting them however, which is, as I mentioned, impossible.
Re:GHCJS - Haskell in the Browser by chongli on Wednesday June 26, 2013 @05:08PM (#5949066)
Yeah, just add goto!
Re:GHCJS - Haskell in the Browser by colanderman on Wednesday June 26, 2013 @10:13PM (#5950350)
Yes, add goto. If JS is going to be the "assembly language of the web", it needs a general branch construct or it will suck.
Re:GHCJS - Haskell in the Browser by carterschonwald on Wednesday June 26, 2013 @01:56PM (#5947700)
Well then I dream of a day when an ecmascript revision makes the breaking changes needed to fix this. Or some sort of clever hack works around that constraint
Re:GHCJS - Haskell in the Browser by luite on Wednesday June 26, 2013 @03:06PM (#5948245)
The change is proposed for ECMAScript 6: http://wiki.ecmascript.org/doku.php?id=harmony:proper_tail_c...

GHCJS currently uses a trampoline, but all calls are in tail position, so when this gets implemented we can easily generate code that uses native JS tail calls.

Like GHC, GHCJS uses its own stack for non-tail calls.

Re:GHCJS - Haskell in the Browser by carterschonwald on Wednesday June 26, 2013 @08:02PM (#5949900)
I think native code GHC has its stack in the standard location, though it manages it explicitly (as most native code languages do). (I'll double check the ghc source later to make sure i'm quibbling correctly)
Re:GHCJS - Haskell in the Browser by colanderman on Wednesday June 26, 2013 @04:06PM (#5948641)
fork threads, use MVars, perform STM

As someone who is very familiar with purely functional languages and with multiprocessor synchronization, I must ask, why would anyone want to use any of these things in Haskell? Aren't two of the primary benefits of Haskell the ability to auto-parallelize, and not needing to reason about state?

Re:GHCJS - Haskell in the Browser by Peaker on Wednesday June 26, 2013 @07:21PM (#5949765)
"Purely functional" is a misnomer. A better description is "typed effects". Haskell doesn't forego effects, it types them. You still have imperative destructive updates if you need them (e.g: to avoid a logarithmic complexity hit, or a constant performance hit). You still may want to write imperative programs, often-times as the backend of a pure functional interface.

Haskell is actually quite good at it, and jokingly referred to as "the world's finest imperative language".

Re:GHCJS - Haskell in the Browser by chongli on Wednesday June 26, 2013 @05:05PM (#5949050)
Haskell doesn't have auto-parallelism. There are some excellent libraries for parallelism (strategies, DPH, repa) but they take some work. True auto-parallelism (a la Parasail) is far more difficult to get right (often due to granularity of work units).
Re:GHCJS - Haskell in the Browser by colanderman on Wednesday June 26, 2013 @07:27PM (#5949788)
Mercury does a decent job of this (not quite auto-parallelism, you need to hint at parallelization points, but it manages granularity for you).