This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ======================================================================================== | |
// Utilities types | |
// ======================================================================================== | |
type TU11 = '(T extends U) and (U extends T)' | |
type TU10 = '(T extends U) and (U NOT extends T)' | |
type TU01 = '(T NOT extends U) and (U extends T)' | |
type TU00 = '(T NOT extends U) and (U NOT extends T)' | |
type Ext<T,U,A,B> = T extends U ? A : B // In type system jargon we can say that "T is assignable to U". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ======================================================================================== | |
// Utilities types | |
// ======================================================================================== | |
type TU11 = '(T extends U) and (U extends T)' | |
type TU10 = '(T extends U) and (U NOT extends T)' | |
type TU01 = '(T NOT extends U) and (U extends T)' | |
type TU00 = '(T NOT extends U) and (U NOT extends T)' | |
type Ext<T,U,A,B> = T extends U ? A : B // In type system jargon we can say that "T is assignable to U". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Message<N extends string = string, D = unknown> = { name: N, data: D } | |
type Context<K0 extends string = string, K1 extends string = string, > = { | |
contextName: K0 | |
aggregateName: K1 | |
aggregateId: string | |
} | |
interface Command<N extends string = string, D = unknown> extends Message<N,D> { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the implementation of the ImmerJs concept but using Lenses and Atomic References. | |
// See bellow to see the immerJs use case I based on: | |
// https://www.smashingmagazine.com/2020/06/better-reducers-with-immer/ | |
// ------------------ LIB ---------------------- | |
// List Module | |
type List<A> = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { serve } from "https://deno.land/[email protected]/http/server.ts"; | |
const s = serve({ port: 8000 }); | |
console.log("http://localhost:8000/"); | |
for await (const req of s) { | |
req.respond({ body: "Hello World\n" }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface FixedArray<Size extends number, A> extends ArrayLike<A> { length: Size } | |
type MyTriple = FixedArray<3,number> | |
const ok_case: MyTriple = [1,2,3] as const // ok ! | |
const erro_case1: MyTriple = [1,2] as const // fewer elements | |
const erro_case2: MyTriple = [1,2,3,4] as const // many elements | |
const erro_case3: MyTriple = [1,2,3] // not constant in static-time | |
const erro_case4: MyTriple = [] as const // well, it's empty my son! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The Essence of A Turing Machine - | |
// AST explorer studies | |
import { hello } from './juca' | |
hello() | |
const arr = [2,hello,3] | |
type Reader<A> = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { foldLeftArray } from "../array/foldLeftArray" | |
import { Maybe } from "./maybe" | |
import { identity } from "./identity" | |
import { Either } from "./either" | |
/** Results in a successful value of type A or an error of type E. This type works like Either, but the semantics enforces the Error Success reasoning */ | |
export type Result<E,A> = { | |
readonly kind: 'Result' | |
readonly unsafeRun: () => (E|A) extends void ? void : E extends void ? A : A | E |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ZIO, ZIO_ } from "../zio/zio" | |
// STREAM | |
// async steam | |
type Stream<E,A> = { | |
readonly kind: 'Stream' | |
readonly identity: () => Stream<E,A> | |
readonly take: (n: number) => Stream<E,readonly A[]> | |
readonly map: <B>(f: (_:A) => B) => Stream<E,B> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Result } from "../result" | |
// ------------------------------------------------ | |
// pseudo-type | |
// ------------------------------------------------ | |
// todo: Similar concept of Maybe.Nothing. Reuse the nothing of maybe ? Or should be the other way around, make Nothing sub type of PseudoType | |
// todo: should be minimized and reused by Nothing | |
// purpose of this type is to save a type and use it in static-time but without have to |