Skip to content

Instantly share code, notes, and snippets.

View ENvironmentSet's full-sized avatar
🎯
Focusing on development of hyogwa

Jaewon Seo ENvironmentSet

🎯
Focusing on development of hyogwa
View GitHub Profile
@ENvironmentSet
ENvironmentSet / waitor.md
Last active December 14, 2018 11:48
Waitor Idea Sketch

Waitor

특정 시점까지 특정 객체에 대한 연산을 미루는 래퍼 객체

// Without Waitor
document.addEventListener('DOMContentLoaded', () => {
  console.log(document.getElementById('a').value);
});
@ENvironmentSet
ENvironmentSet / arguments.md
Last active January 30, 2019 23:04
You don't know arguments object
function problem1(a, b, c) {
  arguments[0] = 100;
  return [a, b, c];
}

problem1(1, 2, 3) // 반환값을 맞추어 보세요!

정답: [100, 2, 3]

@ENvironmentSet
ENvironmentSet / readme.md
Created March 31, 2019 10:07
An Elegant way to define property conditionally

Andrea Simone Costa의 글을 보고 작성한 글 입니다(Andrea의 설명은 읽지 않고 쓰는 글이라 원문과 다르게 설명했을 확률이 높습니다).

요약

spread properties의 문법적, 의미적인 성질을 이용하면 다음과 같이 깔끔하게 조건부로 객체의 프로퍼티를 선언할 수 있습니다.

const condition = true;
const foo = {
@ENvironmentSet
ENvironmentSet / cadt.ts
Last active October 24, 2019 12:44
ClassAsADTDefinition
/**
data List a = Nil | Cons a (List a)
class Monoid a where
mempty :: a
mappend :: a -> a -> a
instance Monoid (List a) where
mempty = Nil
mappend Nil ys = ys
@ENvironmentSet
ENvironmentSet / st-formal.ts
Last active December 30, 2020 11:13
ST Monad In Typescript
// Sorry for poor naming, this example was intented to explain how to use skolem capturing in practise.
interface Stateful<S, A> {
(state: S): [A, S]
}
function fmap<S, A, B>(f: (a: A) => B): (stateful: Stateful<S, A>) => Stateful<S, B> {
return stateful => state => {
const [a, nextState] = stateful(state);
@ENvironmentSet
ENvironmentSet / any.ts
Last active December 18, 2019 08:25
Type safe any in Typescript
type Any = <B>(f: <A>(a: A) => B) => B; // Instead of forall a. a, use it's continuation. (they're isomorphic)
function any<A>(a: A): Any {
return f => f(a);
}
@ENvironmentSet
ENvironmentSet / HKT.ts
Last active August 28, 2023 04:47
Encoding HKTs in typescript without declaration merging
export interface HKT {
param: unknown;
result: unknown;
}
interface NotHKT extends HKT {
result: this['param'] extends true ? false : true;
}
interface FstHKT extends HKT {
@ENvironmentSet
ENvironmentSet / constraints.ts
Last active August 21, 2020 20:50
Generating eliminator for given constraint in typescript
/** If you want to know how to encoding HKTs in typescript, check this:
https://gist.github.com/ENvironmentSet/1662a140f99381bc85fd6be51ecdcbb5
Sorry for messy names, this was only PoC. **/
export interface HKT {
param: unknown;
result: unknown;
}
# First, you must get the previous commit sha, the one before the forced push:
## Hit through terminal
curl -u <username> https://api.github.com/repos/:owner/:repo/events
# Then you can create a branch from this sha:
## Hit through terminal
curl -u <github-username> -X POST -d '{"ref":"refs/heads/<new-branch-name>", "sha":"<sha-from-step-1>"}' https://api.github.com/repos/:owner/:repo/git/refs
@ENvironmentSet
ENvironmentSet / hpack.hsfiles
Created August 5, 2020 13:31 — forked from Ailrun/hpack.hsfiles
Stack templates
{-# START_FILE package.yaml #-}
spec-version: 0.31.0
name: {{name}}
version: 0.1.0.0
# synopsis:
# description:
category: {{category}}{{^category}}Web{{/category}}
homepage: https://github.com/{{github-username}}{{^github-username}}githubuser{{/github-username}}/{{name}}#readme
bug-reports: https://github.com/{{github-username}}{{^github-username}}githubuser{{/github-username}}/{{name}}/issues
author: {{author-name}}{{^author-name}}Author name here{{/author-name}}