Giter VIP home page Giter VIP logo

effect_sandbox's People

Contributors

mw10013 avatar

Watchers

 avatar  avatar

effect_sandbox's Issues

Effect.gen

export const gen: {
  <Eff extends EffectGen<any, any, any>, AEff>(
    f: (resume: Adapter) => Generator<Eff, AEff, any>
  ): Effect<
    [Eff] extends [never] ? never : [Eff] extends [EffectGen<infer R, any, any>] ? R : never,
    [Eff] extends [never] ? never : [Eff] extends [EffectGen<any, infer E, any>] ? E : never,
    AEff
  >
  <Self, Eff extends EffectGen<any, any, any>, AEff>(
    self: Self,
    f: (this: Self, resume: Adapter) => Generator<Eff, AEff, any>
  ): Effect<
    [Eff] extends [never] ? never : [Eff] extends [EffectGen<infer R, any, any>] ? R : never,
    [Eff] extends [never] ? never : [Eff] extends [EffectGen<any, infer E, any>] ? E : never,
    AEff
  >
} = effect.gen

/**
 * @category models
 * @since 2.0.0
 */
export interface EffectGen<R, E, A> {
  readonly _R: () => R
  readonly _E: () => E
  readonly _A: () => A
  readonly value: Effect<R, E, A>

  [Symbol.iterator](): Generator<EffectGen<R, E, A>, A>
}

/**
 * @since 2.0.0
 * @category models
 */
export interface Adapter {
  <R, E, A>(self: Effect<R, E, A>): EffectGen<R, E, A>
  <A, _R, _E, _A>(a: A, ab: (a: A) => Effect<_R, _E, _A>): EffectGen<_R, _E, _A>
  <A, B, _R, _E, _A>(a: A, ab: (a: A) => B, bc: (b: B) => Effect<_R, _E, _A>): EffectGen<_R, _E, _A>
  <A, B, C, _R, _E, _A>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => Effect<_R, _E, _A>): EffectGen<_R, _E, _A>
  <A, B, C, D, _R, _E, _A>(
    a: A,
    ab: (a: A) => B,
    bc: (b: B) => C,
    cd: (c: C) => D,
    de: (d: D) => Effect<_R, _E, _A>
  ): EffectGen<_R, _E, _A>
}

Pipeable

// Effect: pipeable.ts

export interface Pipeable {
  readonly pipe: {
    <A, B>(this: A, ab: (_: A) => B): B
    <A, B, C>(this: A, ab: (_: A) => B, bc: (_: B) => C): C
    <A, B, C, D>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D
    <A, B, C, D, E>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E): E
    <A, B, C, D, E, F>(
      this: A,
      ab: (_: A) => B,
      bc: (_: B) => C,
      cd: (_: C) => D,
      de: (_: D) => E,
      ef: (_: E) => F
    ): F
    <A, B, C, D, E, F, G>(
      this: A,
      ab: (_: A) => B,
      bc: (_: B) => C,
      cd: (_: C) => D,
      de: (_: D) => E,
      ef: (_: E) => F,
      fg: (_: F) => G
    ): G
  }
}

HttpClient.client.fetch()

import { HttpClient } from "@effect/platform";

const response = yield* _(
  request,
  HttpClient.client.fetch(),
  Effect.flatMap((res) => res.json)
);

HttpClient.request

import { HttpClient } from "@effect/platform";

const request = HttpClient.request
  .get("https://api.hubapi.com/crm/v3/objects/contacts/1?archived=false")
  .pipe(HttpClient.request.bearerToken(accessToken));

Effect<R, E, A>

// Effect.ts
import * as core from "./internal/core.js"

export interface Effect<R, E, A> extends Effect.Variance<R, E, A>, Equal.Equal, Pipeable {
  readonly [Unify.typeSymbol]?: unknown
  readonly [Unify.unifySymbol]?: EffectUnify<this>
  readonly [Unify.ignoreSymbol]?: EffectUnifyIgnore
}

  export interface Variance<R, E, A> {
    readonly [EffectTypeId]: VarianceStruct<R, E, A>
  }

  export interface VarianceStruct<R, E, A> {
    readonly _V: string
    readonly _R: (_: never) => R
    readonly _E: (_: never) => E
    readonly _A: (_: never) => A
  }

  export type Context<T extends Effect<any, any, any>> = [T] extends [Effect<infer _R, infer _E, infer _A>] ? _R : never
  export type Error<T extends Effect<any, any, any>> = [T] extends [Effect<infer _R, infer _E, infer _A>] ? _E : never
  export type Success<T extends Effect<any, any, any>> = [T] extends [Effect<infer _R, infer _E, infer _A>] ? _A : never

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.