Hacker News new | past | comments | ask | show | jobs | submit login

What we really need is for some people to turbocharge ghcjs (http://news.ycombinator.com/item?id=1818820), so that we can get optional static type checking in Javascript.

Haskell is great at parsing[1] and great at type checking. So how about it parse the relatively simple JS grammar[2] and do some static checking on JS code?

You could augment existing JS code with an optional accepts/return syntax to provide type annotations:

  foo = function(x) { return [x+1,x+2]}
  foo.accepts = Numeric
  foo.returns = [Numeric, Numeric]
This is similar to Collin Winter's typecheck for python (http://pypi.python.org/pypi/typecheck/), which has some nontrivial bugs but which is conceptually interesting.

[1] You could use Matt Might's new derivative parser if you want to have some fun while doing this (he has a Haskell implementation to boot!)

http://matt.might.net/articles/parsing-with-derivatives/

[2] Real World Haskell has a good JSON example that should be easily extensible to the full syntax: http://book.realworldhaskell.org/read/writing-a-library-work...

EDIT:

Doctor JS by Mozilla is a (very) good start here -- maybe it already does everything we need...

http://doctorjs.org




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: