JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2187
  • Score
    100M100P100Q145611F
  • License MIT

Helper functions to interoperate between the Effect framework and the fp-ts library

Package Exports

  • @inato/effect-fpts-interop
  • @inato/effect-fpts-interop/dist/index.cjs
  • @inato/effect-fpts-interop/dist/index.mjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@inato/effect-fpts-interop) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@inato/effect-fpts-interop

Helper functions to interoperate between the Effect type and the ReaderTaskEither type.

[!NOTE] This repository acts as supporting document for this article that describe how at Inato we successfully migrated to Effect.

Installation

You can install this package via pnpm:

pnpm install @inato/effect-fpts-interop

Usage

portToEffect

import {
  getFptsMapping,
  portToEffect,
  type FptsAccess,
  type FptsConvertible,
} from "@inato/effect-fpts-interop";

interface MeasureString extends FptsConvertible<"measureString"> {
  measure: (value: string) => ReaderTaskEither<unknown, Error, number>
}

interface MeasureStringAccess extends FptsAccess<MeasureString> { }

declare const MeasureStringFpts: {
  measure: (value: string) => ReaderTaskEither<MeasureString, Error, number>
}

const Tag = Context.GenericTag<MeasureString>("MeasureString")

const MeasureString = portToEffect(
  MeasureStringFpts, 
  getFptsMapping(Tag, "measureString")
)

MeasureString.measure("hello 👋") // Effect<number, Error, MeasureString>

portToFpts

import {
  getFptsMapping,
  portToFpts,
  type FptsAccess,
  type FptsConvertible,
} from "@inato/effect-fpts-interop";

interface MeasureString extends FptsConvertible<"measureString"> {
  measure: (value: string) => Effect<number, Error>
}

interface MeasureStringAccess extends FptsAccess<MeasureString> { }

declare const MeasureStringFpts: {
  measure: (value: string) => ReaderTaskEither<MeasureString, Error, number>
}

const Tag = Context.GenericTag<MeasureString>("MeasureString")

const MeasureString = Effect.serviceFunctions(Tag)

const MeasureStringFpts = portToFpts(
  MeasureString, 
  getFptsMapping(Tag, "measureString")
)

MeasureStringFpts.measure("hello 👋") // ReaderTaskEither<MeasureStringAccess, Error, number>

And more.. Have a look at the example section!