Skip to content

Instantly share code, notes, and snippets.

@peter-leonov
peter-leonov / lazy-list.js
Created May 21, 2017 21:07 — forked from gvergnaud/lazy-list.js
Lazy List, implemented with es6 generators
/* ----------------------------------------- *
Lazy List Implementation
* ----------------------------------------- */
// Haskell-like infinite List, implemented with es6 generators
// Lazyness lets you do crazy stuff like
List.range(0, Infinity)
.drop(1000)
.map(n => -n)
@i-am-tom
i-am-tom / bifunctor-profunctor.js
Created June 26, 2017 18:32
The main examples from the "Bifunctor + Profunctor" post.
const { Left, Right } = require('fantasy-eithers')
const daggy = require('daggy')
Function.prototype.map = function (f) {
return x => f(this(x))
}
//- Where everything changes...
const login = user =>
user.name == 'Tom'
import R from 'ramda'
import { account } from 'store/lenses'
export default {
ids: R.view(account.ids),
recentActivity: R.memoize(
state => R.compose(
ids => {
const hash = R.view(account.data, state)
const Day = ({ get, left, right }) => {
const map = f => Day ({
get: f (extract()),
left, right
})
const extend = f =>
Day ({
get: (left, right) => f (Day ({ get, left, right })),
import Maybe from 'crocks/Maybe'
import Star from 'crocks/Star'
import prop from 'crocks/Maybe/prop'
import propOr from 'crocks/helpers/propOr'
import resultToMaybe from 'crocks/Maybe/resultToMaybe'
import tryCatch from 'crocks/Result/tryCatch'
const MaybeStar =
Star(Maybe)
@abiodun0
abiodun0 / view_and_reader_monad.js
Last active September 16, 2021 04:10
React and reader monad from first principles https://codesandbox.io/s/react-composition-rjmzd
import ReactDOM from 'react-dom'
import Reac, { createElement } from 'react'
import { compose, map, ap, pipe } from 'ramda'
import IntlMessageFormat from 'intl-messageformat'
const copyrightNotice = View(({ author, year }) => <p>© {author} {year}</p>)
const Monad = {
do: gen => {
@evilsoft
evilsoft / ours(preds addtion).md
Last active April 14, 2023 06:44
Simple Style Diffs
+ const isValidScore = score =>
+   score >= 70
+
+ const isValidUser = user =>
+   user && user.length > 3

data.reduce((acc, rec) => {
  const { score, user } = rec
import curry from 'crocks/helpers/curry'
import or from 'crocks/logic/or'
import pathSatisfies from 'crocks/predicates/pathSatisfies'
import propSatisfies from 'crocks/predicates/propSatisfies'
const list = [
'nice', 'bad', 'super bad'
]
const data = [

ICS: Cinderella Tokens: An Async/IBC friendly alternative to flash loans

Flashloans are a fascinating economic coordination mechanism that has emerged out the Ethereum architecture as a result of a synchronous, sequential, atomic transaction system. It allows anonymous coordination between capital providers and arbitrageurs because the capital providers can condition providing any capital on protocol enforced guarantee that the entire arbitrage is profitable denominated in the token being lent.

One of the effects of this process has been the it ensures an efficient and healthy liquidation market for the collateral in long term debt instruments. It also enables low cost scaling of economic exploits.

Why don’t flash loans exist in IBC world?

Flash loans are impossible in an IBC world because IBC semantics require finalizing a block on the origin chain rather than on the receiving chain. This makes atomicity for the lender difficult and moves us into the domain of over collateralized lending.

const Either = (() => {
const Right = x => ({
chain: f => f(x),
ap: other => other.map(x),
alt: other => Right(x),
extend: f => f(Right(x)),
concat: other =>
other.fold(
x => other,
y => Right(x.concat(y)),