[Haskell-cafe] Haskell/JS -- better through typeclasses?

Jason Dusek jason.dusek at gmail.com
Sun Apr 26 14:21:05 EDT 2009

2009/04/26 John A. De Goes <john at n-brain.net>:
> 2009/04/26 Jason Dusek:
>> This was what I was originally writing in about, yeah.
>> However, thinking it over I realize there are some serious
>> problems. We really do want to work with a restricted subset
>> of Haskell that is more amenable to translation -- one with
>> finite arrays and most every type translatable to JSON.
> For purposes of cross-platform development, it's important the subset be
> minimally restricted (at least in my case).

  Cross-platform in what sense? Like browser/GTK/QT?

>> I fear that requires us to know, statically, whether
>> potentially infinite structures like lists are finite or
>> infinite. I'm not sure about this but I suspect that's a
>> major stumbling block.
> I think it's easy to determine if something is definitely
> finite (certainly any list passed into an exported Haskell
> function must be finite, since JS doesn't have infinite
> lists).

  That's fair; but internal lists may not be.

> Determining if something is definitely infinite is not as
> easy, but it might be sufficient to use lazy evaluation
> whenever there is a possibility that a structure might be
> infinite. Any function exported to JavaScript must return a
> finite list.

  That is, I think, a most reasonable restriction.

> Annotations would be another way of handling this.

  Why would annotations be preferable to a restricted set of
  types that implement, say,`Foldable` or `Traversible`? I think
  finite collections would be of use for other environments
  where we can't expect a working RTS. In fact I would not be
  surprised if that this sort of thing is not what's been done
  for GPUs by other Haskellers.

Jason Dusek

More information about the Haskell-Cafe mailing list