Skip to content

Commit

Permalink
feat(examples): full update after stdlib fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
emil14 committed Jan 27, 2024
1 parent 54cb073 commit 60f58ad
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 37 deletions.
1 change: 1 addition & 0 deletions examples/0_do_nothing/main.neva
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Program that does literally nothing.
// Here we learn components, ports, networks, connections and port addrs.

components {
Main(enter any) (exit any) {
Expand Down
1 change: 1 addition & 0 deletions examples/1_echo/main.neva
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This program reads a line from stdin and immidiately prints it.
// It does so in a loop - it won't terminate untill you press Ctrl+C.
// Here we learn packages, stdlib, io package, nodes and type parameters

import {
std/io
Expand Down
3 changes: 3 additions & 0 deletions examples/2_hello_world/verbose/main.neva
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Surprisingly "hello world" isn't the simplest program in Nevalang.
// Here we learn constants, compiler directives and blockers.

const {
greeting string 'Hello, World!'
}
Expand Down
3 changes: 3 additions & 0 deletions examples/2_hello_world/with_const_sender/main.neva
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// In this example we use `$` suntatic sugar called "const sender"
// that allows to avoid using compiler directives for sending constants.

const {
greeting string 'Hello, World!'
}
Expand Down
4 changes: 4 additions & 0 deletions examples/2_hello_world/with_then_connection/main.neva
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Now it's time to learn another syntatic sugar `... -> (...)`
// Called "then connections" that allows to avoid explicit usage of blockers.
// It's extremely useful when working with constants to keep code simple.

const {
greeting string 'Hello, World!'
}
Expand Down
3 changes: 3 additions & 0 deletions examples/3_interfaces/main.neva
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Here we learn interfaces and how to use them.
// It's essential to understand bridges.

interfaces {
IExample<T>(msg T) (msg T)
}
Expand Down
2 changes: 2 additions & 0 deletions examples/4_add_numbers/verbose/main.neva
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Here we learn `stream<T>` and streamers

const {
a 1
b 1
Expand Down
2 changes: 2 additions & 0 deletions examples/4_add_numbers/with_bridge/main.neva
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Here we learn how to avoid explicit usage of streamers by using bridges.

const {
a 1
b 1
Expand Down
5 changes: 1 addition & 4 deletions examples/5_add_real_numbers/naive/main.neva
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// Program that adds two numbers typed by user and prints the result.
// The algorithm is:
// 1) read first input, parse it,
// 2) read the second input and parse it too.
// 3) add numbers and print the result.
// Here we learn strconv package and why error handling is important.

import {
std/io
Expand Down
2 changes: 1 addition & 1 deletion examples/5_add_real_numbers/with_error_handling/main.neva
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// handle errors
// Here we learn how to handle errors by fixing this simple program

import {
std/io
Expand Down
4 changes: 2 additions & 2 deletions examples/6_struct_builder/verbose/main.neva
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Here we build structure using custom struct builder component
// in conjunction with compiler directive.
// Here we learn how to build structures
// by creating custom components with compiler directives.

types {
User struct {
Expand Down
4 changes: 3 additions & 1 deletion examples/6_struct_builder/with_sugar/main.neva
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Turns out we can do the same thing using builtin StructBulder component.
// Here we learn how to build structures
// without custom components and compiler directives
// by simply using builtin StructBuilder.

types {
User struct {
Expand Down
13 changes: 9 additions & 4 deletions examples/7_struct_selector/verbose/main.neva
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
// Here we learn how to read struct field
// by using builtin component with compiler directive.

types {
User struct {
age int
name string
pet Pet
}
Pet struct {
name string
}
}

const {
user User {
age: 32
name: 'john'
pet: { name: 'Charley' }
}

path list<string> ['name']
path list<string> ['pet', 'name']
}

components {
Expand Down
5 changes: 4 additions & 1 deletion examples/7_struct_selector/with_selectors/main.neva
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Here we learn how to read struct fields without compiler directives
// by using another one syntax sugare `.` called "struct selectors".

types {
User struct {
age int
Expand All @@ -19,7 +22,7 @@ components {
printer Printer<string>
}
net {
in:enter -> ($u.name -> printer:msg)
in:enter -> ($u.pet.name -> printer:msg)
printer:msg -> out:exit
}
}
Expand Down
24 changes: 0 additions & 24 deletions examples/8_map_selector/main.neva

This file was deleted.

0 comments on commit 60f58ad

Please sign in to comment.