+++
title = "`type`"
weight = 1
+++

Defines a type synonym. These are used purely for readability, *i.e.,* a
type synonym can always be "expanded out" to its definition at any time.

```
topDefn ::= type typeId {tyVarId }= type
```

Examples:

```hs
type Byte     = Bit 8
type Word     = Bit 16
type LongWord = Bit 32
```

These provide commonly used names for certain bit lengths. In a
specification of a processor:

```hs
data RegName = R0 | R1 | ... | R31
type Rdest = RegName
type Rsrc = RegName
data ArithInstr = Add Rdest Rsrc Rsrc
                | Sub Rdest Rsrc Rsrc
```

the last two lines suggest the roles of the registers in the
instructions, and is more readable than:

```hs
data ArithInstr = Add RegName RegName RegName
                | Sub RegName RegName RegName
```
