News for hackers. Stuff that matters.
Re:TypeScript 1.4 sneak peek: union types, type guards, and ... by lobster_johnson on Wednesday November 19, 2014 @02:48PM (#8632183)
Their union type syntax looks like Ceylon's. I rather like it.

Union types with pattern matching would be the logical step, would it not? I wish for something like:

    match getResults() {
      case e: Error: ...
      case r: Results: ...
    }
Re:TypeScript 1.4 sneak peek: union types, type guards, and ... by aikah on Wednesday November 19, 2014 @05:09PM (#8632985)
Here is the issue,at the end of the day,Typescript is just javascript with compile time type checking.Pattern matching would mean introducing "new" semantics which would make the compiled code much less readable than it is today.

Tomorrow if I want to drop Typescript,I can,because it still outputs readable javascript.Introduce something like pattern matching and it will not be an option anymore.

Re:TypeScript 1.4 sneak peek: union types, type guards, and ... by Horusiath on Wednesday November 19, 2014 @05:16PM (#8633024)
I actually like cleanliness of Javascript generated from Typescript code. However I don't think that pattern matching would be more intrusive than, for example, module or class generation. Basically example from above could be compiled down to something like:

    var x = getResults();
    if(x instanceof Error) { ... }
    else if(x instanceof Results) { ... }
Re:TypeScript 1.4 sneak peek: union types, type guards, and ... by lobster_johnson on Wednesday November 19, 2014 @10:07PM (#8634221)
All the TypeScript examples use "instanceof". That's what a pattern matching block like this would compile down to, surely. And pattern matching on literals (eg., [x|xs]) would also translate to perfectly adequate JavaScript.
Re:TypeScript 1.4 sneak peek: union types, type guards, and ... by codygman on Wednesday November 19, 2014 @09:35PM (#8634109)
Have you checked out purescript[0]?

0: http://www.purescript.org/

Re:TypeScript 1.4 sneak peek: union types, type guards, and ... by lobster_johnson on Wednesday November 19, 2014 @10:05PM (#8634214)
Yes, it looks quite nice. I might experiment with it for a personal project at some point. Is it easy to use NPM modules without any extra glue?
Re:TypeScript 1.4 sneak peek: union types, type guards, and ... by codygman on Thursday November 20, 2014 @12:57AM (#8634609)
I believe they can be very easily used if they are CommonJS modules? I'm not sure, but I'm almost positive the amazing Purescript Book[0] has an answer for you.

0: https://leanpub.com/purescript/read