Derw: a short-but-sweet language to leverage types on Javascript platforms.

Install

npm install derw

Or check out the repo on Github

Or follow me on Twitter

Read more of the docs in the Derw book

What?

An ML-language that compiles to TypeScript or JavaScript, with types.
                    
import "./String" as String

type alias Person = {
    name: string,
    age: number
}

sayHi: Person -> string
sayHi person =
    "Hello, " + person.name

type Animal =
    Dog { name: string }
    | Cat { lives: number }

sayHiToAnimal: Animal -> string
sayHiToAnimal animal =
    case animal of
        Dog { name } -> "Who is a good boy? " + name + " is!"
        Cat { lives } -> "You have " + (String.fromNumber lives) + " lives remaining"
                    
                

Why?

You're writing TypeScript, but miss the simplicity of Elm. Taking a types-first approach requires a lot of boilerplate or magical libraries. Writing tsx with React feels wrong. Luckily, Derw is there for you. With interop for TypeScript, Derw allows you to work on your existing codebases and projects in a simpler manner than Elm, while providing you with familiar libraries like the Html package built on the model-view-update structure. Read the announcement blogpost for more info on why

How?

Derw compiles to TypeScript, generating type-safe code. It has a type system to verify that Derw code is correctly typed. Through generating TypeScript it is possible to ensure that interop code between Derw and TypeScript is typesafe.

Features

Changelog

August 2022 July 2022 June 2022 May 2022 April 2022 March 2022 Feburary 2022 January 2022, part 2 January 2022, part 1 December 2021