# Download gist files to `rchain-network` folder
git clone https://gist.github.com/62ef42c4b4557ddc80d2cf80914b2ac4.git rchain-network
# change folder
cd rchain-network
-- Example is presented in Marko's talk | |
-- https://dimjasevic.net/marko/2018/02/12/gave-a-talk-on-types-in-programming/index.html | |
-- This is original source in Idris | |
-- https://gitlab.com/mdimjasevic/uloga-tipova/blob/master/StateMachineProg-done.idr | |
data Grade' = A | B | C | D | E | |
data EssayS = Unassigned | |
| Assigned |
module Parser where | |
-- won't work because type class instances must not be type synonyms | |
-- type Parsera res = String -> (Either String res, String) | |
-- data Parser res = Parser (String -> (Either String res, String)) | |
-- parse (Parser p) = p | |
-- or with `newtype` | |
newtype Parser res = Parser { parse :: String -> (Either String res, String) } |
new compose in { | |
contract compose(input ...@sends) = { | |
for(...@inp <= input) { | |
new apply in { | |
apply!(inp, sends) | | |
contract apply(argsc, @[send ...rest]) = { | |
match rest { | |
[] => { | |
// the last contract is the end of composition and it's called with suplied args | |
// and args returned from previous contract (without return channel) |
I hereby claim:
- I am tgrospic on github.
- I am grospic (https://keybase.io/grospic) on keybase.
- I have a public key ASBAeNTYpzr47xvOjAx-vvnIuZSZCkujsN2nm6lPQIhizwo
To claim this, I am signing this object:
data:text/html,<script> | |
const revBalance = addr => ` | |
new return, rl(\`rho:registry:lookup\`), RevVaultCh, vaultCh in { | |
rl!(\`rho:rchain:revVault\`, *RevVaultCh) | | |
for (@(_, RevVault) <- RevVaultCh) { | |
@RevVault!("findOrCreate", "${addr}", *vaultCh) | | |
for (@maybeVault <- vaultCh) { | |
match maybeVault { | |
(true, vault) => @vault!("balance", *return) | |
(false, err) => return!(err) |
Excellent post by John A De Goes about the critique of tagless-final style of abstracting over program effects and program execution (control flow).
https://degoes.net/articles/zio-environment
In RChain source code tagless-final style is used (mostly) and knowing what are the limitations and where is the hidden complexity, can be very useful. Notes here should help in easier understanding of the points presented in the post.
There are two popular libraries for functional programming in Scala cats and scalaz. Because cats is used in RChain it's also in this examples.
The very basic tool in programming is to be able to create a variable or a parameter that we can use in many contexts just by replacing it with different values. This is a strange way to say the definition of Lambda calculus which is the basis for most programming languages today. At least those languages that use functions.
The next few examples will show how we can go from value level functions to type level functions and how is this syntax "distinction" represented in languages like TypeScript, C#, Scala, Haskell and Idris.
Video: https://youtu.be/-p1QqAilZoI
object rholang { | |
/** | |
* This interface represents terms in our Simple Rholang language. | |
* Everything is a process. | |
*/ | |
trait Process | |
/** | |
* AST of our Simple Rholang language. It's private and accessible only |
object rholang { | |
/** | |
* This interface represents terms in our Simple Rholang language. | |
* Everything is a process. | |
*/ | |
trait Process | |
/** | |
* AST of our Simple Rholang language. It's private and accessible only |