Skip to content

Instantly share code, notes, and snippets.

View amao's full-sized avatar

76 amao

View GitHub Profile
@amao
amao / .Cloud.md
Created August 7, 2020 16:37 — forked from imba-tjd/.Cloud.md
一些免费的云资源

IaaS指提供系统(可以自己选)或者储存空间之类的硬件,软件要自己手动装;PaaS提供软件/框架(可以自己选);SaaS只能使用开发好的软件(卖软件本身);BaaS一般类似于非关系数据库,但各家不通用,有时还有一些其它东西。

其他人的集合

@amao
amao / example.js
Created June 25, 2019 18:39 — forked from staltz/example.js
Build your own RxJS
function createObservable(subscribe) {
return {
subscribe,
pipe: function(operator) {
return operator(this);
},
};
}
const numberObservable = createObservable(function(observer) {
@amao
amao / free_monad.cs
Created June 21, 2019 21:14 — forked from arturaz/free_monad.cs
Free Monad implementation in C# (CSharp)
using System;
namespace main {
// Modeled against
// https://medium.com/@olxc/free-monads-explained-pt-1-a5c45fbdac30
//
// Higher kind simulation from https://medium.com/@johnmcclean/simulating-higher-kinded-types-in-java-b52a18b72c74
static class Id {
public struct W {}
@amao
amao / HKT.swift
Created December 3, 2018 19:00 — forked from anandabits/HKT.swift
Emulating HKT in Swift
// This example shows how higher-kinded types can be emulated in Swift today.
// It acheives correct typing at the cost of some boilerplate, manual lifting and an existential representation.
// The technique below was directly inspired by the paper Lightweight Higher-Kinded Polymorphism
// by Jeremy Yallop and Leo White found at http://ocamllabs.io/higher/lightweight-higher-kinded-polymorphism.pdf
/// `ConstructorTag` represents a type constructor.
/// `Argument` represents an argument to the type constructor.
struct Apply<ConstructorTag, Argument> {
/// An existential containing a value of `Constructor<Argument>`
/// Where `Constructor` is the type constructor represented by `ConstructorTag`
@amao
amao / compose.dart
Created May 10, 2018 02:51
Dart Functional Programming
void main() {
var test = compose([add(1), subtract(10)]);
print(test(2));// 10-2+1=9
}
add(int x) {
return (int y) => x + y;
}
subtract(int x) {