Articles

Flow Typing with Constrained Types

Flow-sensitive typing (a.k.a. “Flow Typing”) is definitely getting more popular these days. Ceylon, Kotlin, TypeScript, Racket, Whiley all support flow typing in some form. Then, of course, there’s Facebook Flow and the list goes on!

Recently, I’ve made some fairly major updates to the internals of the Whiley compiler (basically, redesigning the intermediate language). . . . → Read More: Flow Typing with Constrained Types

Understanding why Union Types are useful

The Whiley programming language uses union types as a way of combining types together.  Here’s a simple example to illustrate:

function indexOf(string str, char c) => null|int: for i in 0..|str|: if str[i] == c: return i // found a match // didn’t find a match return null

Here, the type null|int is a . . . → Read More: Understanding why Union Types are useful

Formalising Flow Typing with Union, Intersection and Negation Types

The Whiley language takes an unusual approaching to static typing called flow typing.  This helps to give Whiley the look-and-feel of a dynamically typed language.  The key idea behind flow typing is to allow variables to have different types at different points in a program.  For example, consider the following code written in a . . . → Read More: Formalising Flow Typing with Union, Intersection and Negation Types

Groovy 2.0 uses Flow Typing!

Groovy 2.0 has just been released, and it contains something rather interesting … optional flow typing!  For those who don’t know much about the language, Groovy is a JVM-based dynamically typed language which is similar to Java, but more compact.  And, being dynamically typed means that there’s no need for any cumbersome type declarations.

. . . → Read More: Groovy 2.0 uses Flow Typing!

Flow Typing for References in Whiley

The Whiley language splits into a fully functional “core” and an imperative “outer layer”.  References and objects do not exist within the functional core.  However, they can exist within the imperative outer layer and are necessary for supporting state and other side-effecting computation.  Here’s a simple example:

define Buffer as ref { [int] items . . . → Read More: Flow Typing for References in Whiley

Variable Scoping for Try-Catch Blocks in Whiley

A friend of mine was talking about how variable scoping for try-catch blocks in Java really frustrated him sometimes.  Specifically, the problem was related to variables declared inside try blocks not being visible in their catch handlers. The example would go something like this:

int val; try { int tmp = f(); // cannot . . . → Read More: Variable Scoping for Try-Catch Blocks in Whiley

Termination of Flow Typing in Whiley

Whiley uses flow typing to give it the look-and-feel of a dynamically typed language (see this page for more on flow typing).  In short, flow typing means that variables can have different types at different program points.  For example:

define Node as { int data, Tree left, Tree right } define Tree as null . . . → Read More: Termination of Flow Typing in Whiley