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 { pipe } from "@effect-ts/core" | |
import * as T from "@effect-ts/core/Effect" | |
import * as P from "@effect-ts/core/Effect/Promise" | |
import { tuple } from "@effect-ts/core/Function" | |
import * as O from "@effect-ts/core/Option" | |
export class ConcurrencyLock { | |
executing: P.Promise<never, void>[] = [] | |
constructor(readonly maxConcurrency: number) {} |
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
class DataLoader<K, R, E, A> { | |
hitMap: HM.HashMap<K, number> = HM.make(); | |
promiseMap: HM.HashMap<K, P.Promise<E, A>> = HM.make(); | |
constructor(readonly resolve: (key: K) => T.Effect<R, E, A>) {} | |
acquire(key: K): readonly [isFirst: boolean, promise: P.Promise<E, A>] { | |
return pipe( | |
HM.get_(this.promiseMap, key), |
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
/** | |
* @tsplus type Codec | |
*/ | |
export interface Codec<A> { | |
decode: (value: unknown) => E.Either<string, A>; | |
encode: (value: A) => unknown; | |
} | |
/** |
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
/* Just a fake NodeJS db api exposed by mysql, mssql, etc...*/ | |
interface FakeTrans {} | |
interface FakeConnection { | |
query(sql: string, trans?: FakeTrans): Promise<ResultSet>; | |
beginTransaction(): Promise<FakeTrans>; | |
commitTransaction(trans: FakeTrans): Promise<void>; | |
rollbackTransaction(trans: FakeTrans): Promise<void>; | |
close(): Promise<void>; | |
} | |
declare function fakeConnect(): Promise<FakeConnection>; |
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
/* Just a fake NodeJS db api exposed by mysql, mssql, etc...*/ | |
interface FakeTrans {} | |
interface FakeConnection { | |
query(sql: string, trans?: FakeTrans): Promise<ResultSet>; | |
beginTransaction(): Promise<FakeTrans>; | |
commitTransaction(trans: FakeTrans): Promise<void>; | |
rollbackTransaction(trans: FakeTrans): Promise<void>; | |
} | |
declare function fakeConnect(): Promise<FakeConnection>; |
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 * as E from "@effect-ts/core/Either"; | |
import * as O from "@effect-ts/core/Option"; | |
import * as D from "@effect-ts/core/Collections/Immutable/Dictionary"; | |
import * as CA from "@effect-ts/core/Case"; | |
import * as C from "@effect-ts/core/Collections/Immutable/Chunk"; | |
import * as Q from "@effect-ts/query/Query"; | |
import * as T from "@effect-ts/core/Effect"; | |
import * as CRM from "@effect-ts/query/CompletedRequestMap"; | |
import * as RQ from "@effect-ts/query/Request"; | |
import * as DS from "@effect-ts/query/DataSource"; |
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 { Ref } from "@effect-ts/system/Ref"; | |
import { Option } from "@effect-ts/core/Classic/Option"; | |
import { Either } from "@effect-ts/core/Classic/Either"; | |
import { Request } from "src/Request"; | |
/** | |
* A `BlockedRequest[A]` keeps track of a request of type `A` along with a | |
* `Ref` containing the result of the request, existentially hiding the result | |
* type. This is used internally by the library to support data sources that | |
* return different result types for different requests while guaranteeing that |
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
> frontend-fp-ts@0.0.0 prebuild C:\Bus\pwa-ts\packages\frontend-fp-ts | |
> npm run clean | |
> frontend-fp-ts@0.0.0 clean C:\Bus\pwa-ts\packages\frontend-fp-ts | |
> rimraf ./dist | |
> frontend-fp-ts@0.0.0 build C:\Bus\pwa-ts\packages\frontend-fp-ts |
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 { HKT, Kind, Kind2, URIS, URIS2 } from "fp-ts/lib/HKT"; | |
import * as IO from "fp-ts/lib/IO"; | |
import * as TR from "fp-ts/lib/Tree"; | |
import { pipe } from "fp-ts/lib/function"; | |
import * as O from "fp-ts/lib/Option"; | |
import { Lens } from "monocle-ts"; | |
type MarsElementProps = { | |
disabled: false; | |
hidden: false; |
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 React from 'react' | |
interface ButtonProps { | |
shape: 'circle'|'rectangle'|'oval' | |
} | |
function Button(props: ButtonProps) { | |
// renders some pretty button | |
return <button>Heyo</button> | |
} |