Added documentation #730

Merged
zxq9 merged 18 commits from github/fork/radrow/doc-revolution into lima 2020-03-10 20:39:40 +09:00
2 changed files with 41 additions and 41 deletions
Showing only changes of commit edd76d2878 - Show all commits

View File

@ -224,28 +224,28 @@ so even cyclic includes should be working without any special tinkering.
### Types ### Types
Sophia has the following types: Sophia has the following types:
| Type | Description | Example | | | Type | Description | Example |
| ---------- | ------------------------------- | -------: | | |----------------------|---------------------------------------------------------------------------------------------|--------------------------------------------------------------|
| int | A 2-complement integer | ```-1``` | | | int | A 2-complement integer | ```-1``` |
| address | Aeternity address, 32 bytes | ```Call.origin``` | | | address | Aeternity address, 32 bytes | ```Call.origin``` |
| bool | A Boolean | ```true``` | | | bool | A Boolean | ```true``` |
| bits | A bit field | ```Bits.none``` | | | bits | A bit field | ```Bits.none``` |
| bytes(n) | A byte array with `n` bytes | ```#fedcba9876543210``` | | | bytes(n) | A byte array with `n` bytes | ```#fedcba9876543210``` |
| string | An array of bytes | ```"Foo"``` | | | string | An array of bytes | ```"Foo"``` |
| list | A homogeneous immutable singly linked list. | ```[1, 2, 3]``` | | | list | A homogeneous immutable singly linked list. | ```[1, 2, 3]``` |
| ('a, 'b) => 'c | A function. Parentheses can be skipped if there is only one argument | ```(x : int, y : int) => x + y``` | | | ('a, 'b) => 'c | A function. Parentheses can be skipped if there is only one argument | ```(x : int, y : int) => x + y``` |
| tuple | An ordered heterogeneous array | ```(42, "Foo", true)``` | | | tuple | An ordered heterogeneous array | ```(42, "Foo", true)``` |
| record | An immutable key value store with fixed key names and typed values | ``` record balance = { owner: address, value: int } ``` | | | record | An immutable key value store with fixed key names and typed values | ``` record balance = { owner: address, value: int } ``` |
| map | An immutable key value store with dynamic mapping of keys of one type to values of one type | ```type accounts = map(string, address)``` | | | map | An immutable key value store with dynamic mapping of keys of one type to values of one type | ```type accounts = map(string, address)``` |
| option('a) | An optional value either None or Some('a) | ```Some(42)``` | | | option('a) | An optional value either None or Some('a) | ```Some(42)``` |
| state | A user defined type holding the contract state | ```record state = { owner: address, magic_key: bytes(4) }``` | | | state | A user defined type holding the contract state | ```record state = { owner: address, magic_key: bytes(4) }``` |
| event | An append only list of blockchain events (or log entries) | ```datatype event = EventX(indexed int, string)``` | | | event | An append only list of blockchain events (or log entries) | ```datatype event = EventX(indexed int, string)``` |
| hash | A 32-byte hash - equivalent to `bytes(32)` | | | | hash | A 32-byte hash - equivalent to `bytes(32)` | |
| signature | A signature - equivalent to `bytes(64)` | | | | signature | A signature - equivalent to `bytes(64)` | |
| Chain.ttl | Time-to-live (fixed height or relative to current block) | ```FixedTTL(1050)``` ```RelativeTTL(50)``` | | | Chain.ttl | Time-to-live (fixed height or relative to current block) | ```FixedTTL(1050)``` ```RelativeTTL(50)``` |
| oracle('a, 'b) | And oracle answering questions of type 'a with answers of type 'b | ```Oracle.register(acct, qfee, ttl)``` | | | oracle('a, 'b) | And oracle answering questions of type 'a with answers of type 'b | ```Oracle.register(acct, qfee, ttl)``` |
| oracle_query('a, 'b) | A specific oracle query | ```Oracle.query(o, q, qfee, qttl, rttl)``` | | | oracle_query('a, 'b) | A specific oracle query | ```Oracle.query(o, q, qfee, qttl, rttl)``` |
| contract | A user defined, typed, contract address | ```function call_remote(r : RemoteContract) = r.fun()``` | | | contract | A user defined, typed, contract address | ```function call_remote(r : RemoteContract) = r.fun()``` |
### Literals ### Literals
| Type | Constant/Literal example(s) | | Type | Constant/Literal example(s) |

View File

@ -13,25 +13,25 @@ aeternity/protocol repo in contracts/sophia.md file. Thanks!
Sophia language offers standard library that consists of following namespaces: Sophia language offers standard library that consists of following namespaces:
- [Bits](##Bits) - [Bits](#Bits)
- [String](##String) - [String](#String)
- [Bytes](##Bytes) - [Bytes](#Bytes)
- [Int](##Int) - [Int](#Int)
- [Map](##Map) - [Map](#Map)
- [Address](##Address) - [Address](#Address)
- [Crypto](##Crypto) - [Crypto](#Crypto)
- [Auth](##Auth) - [Auth](#Auth)
- [Oracle](##Oracle) - [Oracle](#Oracle)
- [AENS](##AENS) - [AENS](#AENS)
- [Contract](##Contract) - [Contract](#Contract)
- [Call](##Call) - [Call](#Call)
- [Chain](##Chain) - [Chain](#Chain)
- [List](##List) - [List](#List)
- [Option](##Option) - [Option](#Option)
- [Func](##Func) - [Func](#Func)
- [Pair](##Pair) - [Pair](#Pair)
- [Triple](##Triple) - [Triple](#Triple)
- [BLS12_381](##BLS12_381) - [BLS12_381](#BLS12_381)
# Builtin namespaces # Builtin namespaces