Skip to content

Instantly share code, notes, and snippets.

Avatar

WJH wongjiahau

  • Malaysia
View GitHub Profile
@wongjiahau
wongjiahau / Ohm js grammar
Last active Nov 26, 2021
IBX (Infix Binary Expression)
View Ohm js grammar
// Note: the following grammar has not yet included Unary Tree
Ibx {
Exp
= BinaryExp
BinaryExp
= BinaryExp PriExp PriExp -- BinaryExp
| PriExp
PriExp
@wongjiahau
wongjiahau / solution.apl
Created Oct 10, 2021
Find the minimum missing integers
View solution.apl
/,~
@wongjiahau
wongjiahau / node_modules-graphql-execution-execute.js
Created May 25, 2021
GraphQL Profiling (look at spongebob comment)
View node_modules-graphql-execution-execute.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.execute = execute;
exports.executeSync = executeSync;
exports.assertValidExecutionArguments = assertValidExecutionArguments;
exports.buildExecutionContext = buildExecutionContext;
exports.collectFields = collectFields;
@wongjiahau
wongjiahau / Proof.ts
Created May 3, 2021
Proving Modus Ponens and Modus Tollens in Typescript
View Proof.ts
export const modus_ponens
// Proposition
// Given: A => B and A
// We can conclude: B
: <A, B>(f: (a: A) => B, a: A) => B
= <A, B>(f: (a: A) => B, a: A) => f(a)
// Note, in intuitionistic logic, ~A (a.k.a NOT A), is represented as A => never
export const modus_tollens
// Proposition:
@wongjiahau
wongjiahau / example.md
Last active Mar 18, 2021
Lambda + Let expression Unified Syntax
View example.md

Lambdas using Let Notation

Introduction

As we all know, let expression is actually just a syntactic sugar for immediately invoked lambda expression (IILA). Actually not entirely correct, as pointed out in this comment.

For example, in Haskell:

let x = a in b

is the same as

@wongjiahau
wongjiahau / testing.ts
Last active Jul 21, 2020
Testing deno import url
View testing.ts
export const x = import.meta.url
@wongjiahau
wongjiahau / import_all.ts
Created Jun 9, 2020
For testing compile speed in Deno
View import_all.ts
import * as _0 from 'https://deno.land/x/a0/mod.ts'
import * as _1 from 'https://deno.land/x/cmd/mod.ts'
import * as _2 from 'https://deno.land/x/adka_server/mod.ts'
import * as _3 from 'https://deno.land/x/actdb/mod.ts'
import * as _4 from 'https://deno.land/x/airtable/mod.ts'
import * as _5 from 'https://deno.land/x/adka/mod.ts'
import * as _6 from 'https://deno.land/x/abc/mod.ts'
import * as _7 from 'https://deno.land/x/amqp/mod.ts'
import * as _8 from 'https://deno.land/x/alosaur/mod.ts'
import * as _9 from 'https://deno.land/x/ascii_table/mod.ts'
View terser.min.js
//@ts-nocheck
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("source-map")):"function"==typeof define&&define.amd?define(["exports","source-map"],t):t((e=e||self).Terser={},e.sourceMap)}(this,(function(e,t){"use strict";function n(e){return e.split("")}function i(e,t){return t.includes(e)}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;class r extends Error{constructor(e,t){super(),this.name="DefaultsError",this.message=e,this.defs=t}}function o(e,t,n){!0===e&&(e={});const i=e||{};if(n)for(const e in i)if(D(i,e)&&!D(t,e))throw new r("`"+e+"` is not a supported option",t);for(const n in t)if(D(t,n))if(e&&D(e,n))if("ecma"===n){let t=0|e[n];t>5&&t<2015&&(t+=2009),i[n]=t}else i[n]=e&&D(e,n)?e[n]:t[n];else i[n]=t[n];return i}function a(){}function s(){return!1}function u(){return!0}function c(){return this}function l(){return null}var f=function(){function e(e,o,a){var s,u=[],c=[];function l(){var l=o(e[s],s),f=l instanceof r;return f&&(l=l.v),l instanceof
View funcords.js
/*
Funcords is a feature that combine functions and records.
If you think about it, record is actually a dependently typed function,
where the output type depends on the input type.
For example,
r = {'x': 1, 'y': 'yo'}
View untyped_record_calculus.c
// Record type
{}: `{}
// construction
{x = {}}: `{x: `{}}
// destruction
{x: `{}} = {x = {}}
// abstraction