Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Shake html code, as a test #29

Open
ndmitchell opened this issue Nov 5, 2015 · 3 comments
Open

Port Shake html code, as a test #29

ndmitchell opened this issue Nov 5, 2015 · 3 comments

Comments

@ndmitchell
Copy link

Shake has a bunch of somewhat-functional Javascript, written by a functional programmer. It might serve as a good medium-size test case. In particular, https://github.com/ndmitchell/shake/tree/db06af5736cc031308f05aed87c21b0a5e06a295/html contains:

  • shake-util.js - a bunch of very simple utilities
  • shake-logic.js - some much more complex processing
  • shake-test.js - a test suite for those two modules
  • shake-ui.js - hooking the logic up with jQuery and Flot

I'm currently porting that to TypeScript, see https://github.com/ndmitchell/shake/tree/master/html/ts

If infernu could handle it, and had explicit and checked type signatures, I'd consider moving to it. Using a Haskell-based Javascript checker makes things like generation and management much easier.

If you aren't interested in test cases at this time, feel free to close this issue.

@sinelaw
Copy link
Owner

sinelaw commented Nov 5, 2015

This is a good test case.

I've made some changes to have it successfully pass the current version of infernu. Here's the changed version: https://gist.github.com/sinelaw/e9b394cade8642e4a9c6
This code highlights several issues in infernu:

  1. Missing support for "in" syntax (e.g. if (!(x in seen)) in the cache examples), also there's no support for hasOwnProperty which would have also worked here.
  2. Inferred row types are indeed fully general, but a major drawback of that is how exceedingly detailed and unreadable they are. For example:
/*       sum : ( { get length: Number
                 , get =[]: Rnt.(Number -> Number) | m} -> Number) */
function sum(xs) // :: Num a => [a] -> a

Infernu doesn't assume xs is an array, but that would have been so much clearer and it's anyway the only valid type you can construct in JS that has numeric indices.

  1. No support for type-casing as used in the regexp/string wrappers, though this is known and problematic to support anyway.
  2. No support for Maybe a as used in the plural function. There's a branch of infernu that has a basic implementation.

Also, other issues.

@vendethiel
Copy link

Does infernu account for key stringification?

@sinelaw
Copy link
Owner

sinelaw commented Nov 6, 2015

When types are not otherwise restricted It can't assume bracket causes
stringification, in x[k] if k can be a number and x an array.
On Nov 6, 2015 10:55 AM, "ven" notifications@github.com wrote:

Does infernu account for key stringification?


Reply to this email directly or view it on GitHub
#29 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants