Get : Typed

motivations for using types

edit

Get Typed

Types create guarantees. They describe properties of a program that can be verified without running it.

welcome.ts
export const run = () : void => {
    $gt.log("Welcome to Get Typed");
    $gt.canvas(100, ctx => {
        const fill = $gt.randomInt(0, 0xaaaaaa).toString(16);
        ctx.fillStyle = `#${fill}`;
        ctx.fillRect(30, 15, 5, 23);
        ctx.fillRect(65, 15, 5, 23);
        ctx.fillRect(47, 47, 6, 6);
        ctx.beginPath();
        ctx.arc(50, 65, 26, Math.PI, 2*Math.PI, true);
        ctx.closePath();
        ctx.fill();
    });
};

Types can be used for…

Catching head-desk mistakes

Static checks and guarantees

  • Configuration
  • Dependency injection
  • User permissions
  • Resource access restrictions
  • Resource lifetime scope

More

  • Statically restricted effects
  • Safe deep immutable updates
  • Statically calculated partial record fetch