// Computations with extensible environment, error handling, and asynchronicity | |
// I recently reviewed some F# code that turned out to be using | |
// | |
// Dependency Interpretation | |
// https://fsharpforfunandprofit.com/posts/dependencies-4/ | |
// | |
// and got thinking about whether one could construct a usable Zio like monad | |
// | |
// https://zio.dev/ |
This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/
the command zig run my_code.zig
will compile and immediately run your Zig
program. Each of these cells contains a zig program that you can try to run
(some of them contain compile-time errors that you can comment out to play
with)
I recently stumbled upon Falsehoods programmers believe about time zones, which got a good laugh out of me. It reminded me of other great lists of falsehoods, such as about names or time, and made me look for an equivalent for Ethereum. Having found none, here is my humble contribution to this set.
Calling estimateGas
will return the gas required by my transaction
Calling estimateGas
will return the gas that your transaction would require if it were mined now. The current state of the chain may be very different to the state in which your tx will get mined. So when your tx i
/* | |
* Very simple test runner for nodejs: | |
* | |
* Supports: | |
* | |
* before, after, beforeAll, afterAll | |
* fixture object passed to each test, that before/after/beforeAll/afterAll can modify | |
* -[t]est option on command line to pick tests to run | |
* -[l]inear option on command to disable parallel | |
* built in fixture logger, captures log lines, adds line numbers/file names/timestamps |
module Program = | |
type InMemoryDb(replica: ReplicaId) = | |
let snapshot = ref null | |
let mutable events : Map<uint64,obj> = Map.empty | |
interface Db with | |
member _.SaveSnapshot state = async { snapshot := (box state) } | |
member _.LoadSnapshot<'s>() = async { | |
match !snapshot with |
import React from "react"; | |
type NoData = { | |
_type: "NO_DATA"; | |
}; | |
type Data<T> = { | |
_type: "DATA"; | |
data: T; | |
}; |
{-# language FlexibleContexts #-} | |
{-# language TypeOperators #-} | |
module DKT where | |
import Control.Monad (guard) | |
import Control.Monad.Error.Class (throwError) | |
import Control.Monad.Trans (lift) | |
import Control.Monad.Trans.State | |
import Control.Monad.Trans.Writer |
Option<T> |
non-Option (T | undefined ) |
|
---|---|---|
accessing property | userOption.map(user => user.age) |
userNullish?.age |
calling a method | userOption.map(user => user.fn()) |
userNullish?.fn() |
providing fallback | ageOption.getOrElse(0) |
ageNullish ?? 0 |
filter | ageOption.filter(checkIsOddNumber) |
`ageNull |
namespace Maybe | |
{ | |
public struct Maybe<T> | |
{ | |
public bool HasValue { get; } | |
public T Value { get; } | |
private Maybe(T value) | |
{ | |
HasValue = true; |