Skip to content

Commit

Permalink
primitive types
Browse files Browse the repository at this point in the history
  • Loading branch information
tjjfvi committed Jan 2, 2025
1 parent 0a57f51 commit d565c59
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 8 deletions.
14 changes: 6 additions & 8 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

[Introduction](./README.md)

- [Getting Started]()
- [Getting Started](./starting/index.md)
- [Installation](./starting/installation.md)
- [Hello, world!](./starting/hello-world.md)

- [Vine Language Features]()
- [The Usual](./features/usual.md)
- [Types]()
- [Types](./features/types/index.md)
- [Primitive Types](./features/types/primitives.md)
- [Standard Types]()
- [Structs]()
- [Enums]()
- [Methods]()
- [IO](./features/io.md)
- [Patterns](./features/patterns.md)
Expand All @@ -30,9 +34,3 @@
- [Ivy's Interaction System](./ivy/interaction-system.md)
- [Statistics](./ivy/statistics.md)
- [Extrinsics]()

---

[Notes](./notes.md)

[Scratch](./scratch.md)
1 change: 1 addition & 0 deletions docs/src/features/types/enums.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Enums
12 changes: 12 additions & 0 deletions docs/src/features/types/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Types

Vine is statically typed. Every expression has a type, like `Bool` or
`List[N32]`. Type parameters are written in square brackets.

Types fall in to several categories:

- [primitive types](./primitives.md) are fundamental types defined by the
compiler
- [standard types](./primitives.md) are commonly-used types defined by the
standard library
- [structs](./structs.md) and [enums](./enums.md) are user-defined types
56 changes: 56 additions & 0 deletions docs/src/features/types/primitives.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Primitive Types

## `N32`

The type `N32` describes natural numbers[^nats], represented with 32 bits of
precision.

`N32` values can be written as literals in decimal (`46`), hex (`0x2e`), or
binary (`0b101110`). Digits can be separated with underscores (`1_000_000`).

`N32`s support the usual arithmetic and bitwise operators (`4 * 11 + 2`,
`5 << 3 | 6`)

## `F32`

The type `F32` describes 32-bit floating-point numbers (following IEEE 754).

`F32` values can be written as literals (`4.6e1`). The decimal point is
required.

`F32`s support the usual arithmetic operators (`3.6 * 12.3 + 1.72`).

## `Char`

The type `Char` describes Unicode code points. `Char`s are primarily used within
`List`s to form `String`s.

`Char` values can be written as literals using single quotes (`'.'`).

`Char`s support adding an `N32`, resulting in another `Char` (`'a' + 4`), as
well as subtracting another `Char`, resulting in an `N32` (`'G' - 'A'`).

## `Bool`

The type `Bool` describes booleans.

The two `Bool` values can be written as literals (`true`, `false`).

`Bool`s support the usual short-circuiting logical operators (`&&`, `||`, `!`)
and non-short-circuiting ("bitwise") operators (`&`, `|`, `^`).

Expressions that evaluate to booleans are called [conditions](./conditions.md).

## `IO`

`IO` is a special primitive type used to interact with the outside world. Values
of this type cannot be explicitly constructed; instead, an `IO` handle is passed
in to `main` at the start of the program. See the section on [IO](../io.md) for
more detail.

---

[^nats]: Natural numbers are non-negative integers. In other programming
languages, they are often referred to as "unsigned integers". Seeing as
positive integers do have a sign (namely, a positive sign), the only truly
unsigned integer is zero.
1 change: 1 addition & 0 deletions docs/src/features/types/standard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Standard
1 change: 1 addition & 0 deletions docs/src/features/types/structs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Structs
4 changes: 4 additions & 0 deletions docs/src/starting/index.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Getting Started

## [Installation](./installation.md)

## [Hello, world!](./hello-world.md)

0 comments on commit d565c59

Please sign in to comment.