Types

Wipple has a powerful static type system that works similarly to Haskell’s. In short, every expression has a type, which can be expressed using the :: operator (pronounced “is a”):

42 :: Number -- "42 is a number"
"Hello" :: Text
'(1 2 3) :: List Number
x -> x :: Number -> Number

You can also create your own types with type:

Name : type Text

Person : type {
    name :: Name
    age :: Number
}

Color : type {
    Red
    Orange
    Yellow
    Green
    Blue
    Purple
}

Maybe-Number : type {
    Some Number
    None
}

By convention, variables representing types and variants of enums are capitalized.

The Maybe-Number type above can be made more general using type functions, which use a => arrow:

Maybe : A => type {
    Some A
    None
}

This also works on other values, like regular functions:

it :: A => A -> A
it : x -> x

By convention, generic types are named A, B, C, etc., but you should try to give a more specific name if applicable.

Finally, you can use an underscore (_) to represent a placeholder type:

Identity : A => -> type (A -> A)
(x :: Number) -> x :: Identity _ -- inferred as Identity Number