Skip to content

Commit

Permalink
wip(spec/ts)
Browse files Browse the repository at this point in the history
  • Loading branch information
emil14 committed Mar 2, 2024
1 parent a8dec87 commit 34af3e8
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 3 deletions.
2 changes: 1 addition & 1 deletion content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ component Main(start) (stop) {

Nevalang operates on a flow-based programming model, where components are connected through inputs and outputs. This eliminates the need for low-level instructions like "call/return" and state manipulations, empowering you to reason about programs in a more natural way.

### Effortless Concurrency
### Implicit Parallelism

FBP allows messages to flow concurrently across connections. This fundamental shift from synchronous to asynchronous operations by default enables seamless parallel computation, without the complexities of mutexes, channels, or promises, and avoids common pitfalls like deadlocks and race conditions. First-class support for streaming data processing allows the system to operate at maximum speed.

Expand Down
76 changes: 74 additions & 2 deletions content/docs/spec/type-system/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,78 @@
---
title: Type System
title: Type System (WIP)
weight: 2
---

WIP
Nevalang has strong static structural type-system

- **Strong** means that there's no implicit type convertions
- **Static** means that semantic analysis for type-safety happens at compile time, not run-time
- **Structural** means that types are compatible if their structure is compatible. Unlike nominative sub-typing, names of the types does not matter. This also means that type can carry more information than needed and still be compatible.

## Base Types

These are types that doesn't have definition in neva source code. Instead compiler is aware of them and knows how to handle them:

- _any_
- _maybe_
- _boolean_
- _integer_
- _float_
- _string_
- _map_
- _list_
- _enum_
- _union_
- _structure_

## Any (Top-Type)

`any` is a _top-type_. It means that any other type is a _sub-type_ of any. That means you can pass any type everywhere `any` is expected. However, since `any` doesn't tell anything about the type, you cannot pass message of type `any` anywhere where more concrete type is expected. You need to either rewrite your code without using any or explicitly cast `any` to concrete type.

## Maybe

Maybe represents value that maybe do not exist. One must unwrap maybe before using the actual value.

## Boolean

Boolean type has only two possible values `true` and `false`

## Integer

Integer is 64 bit integer number

## Float

Integer is 64 bit floating point number

## Strings

Strings are immutable utf encoded byte arrays

## Maps

Maps are unordered key-value pairs with dynamic set of keys. All values must have the same type

## List

List is a dynamic array that grows as needed. All values in the list must have the same type.

## Enums

Enums are set fixed set of values (members) each with its own name. They are represented in memory like integer numbers.

## Union

Union is a _sum type_. It defines set of possible types.

## Struct

Structures are product types (records) - compile-time known set of fields with possibly different types.

## Custom Types

User is allowed to create custom types based on base-types.

---

Further section needs some work. This is WIP document.

0 comments on commit 34af3e8

Please sign in to comment.