Skip to content

0.1.3

Compare
Choose a tag to compare
@xzhayon xzhayon released this 31 May 09:11
· 76 commits to main since this release

Added

  • Add AggregateError inspired from TC39.

  • Add decode method to Type module to help wrapping io-ts Errors into an Error subclass.

  • Add unit tests for the set function of the Redis module.

  • Add Has module and enhance ReaderTaskEither for smart dependencies management (inspired by Effect-TS):

    // Foo.ts
    import { TaskEither } from 'fp-ts/TaskEither'
    import { $has, $readerTaskEither } from 'fortepiano'
    
    export interface Foo {
      bar(a: number): TaskEither<Error, string>
    }
    
    export const TagFoo = $has.tag<Foo>()
    
    export const $foo = {
      bar: $readerTaskEither.derivesTaskEither(TagFoo, 'bar'),
    }
    // Bar.ts
    import { IOEither } from 'fp-ts/IOEither'
    import { $has, $readerTaskEither } from 'fortepiano'
    
    export interface Bar {
      (a: string): IOEither<Error, boolean>
    }
    
    export const TagBar = $has.tag<Bar>()
    
    export const bar = $readerTaskEither.deriveIOEither(TagBar)
    // index.ts
    import { $has } from 'fortepiano'
    import { ioEither, readerTaskEither, taskEither } from 'fp-ts'
    import { pipe } from 'fp-ts/function'
    import { TagBar, bar } from './Bar'
    import { $foo, TagFoo } from './Foo'
    
    // const a: ReaderTaskEither<Has<Foo> & Has<Bar>, Error, boolean>
    const a = pipe($foo.bar(42), readerTaskEither.chainW(bar))
    
    // const b: TaskEither<Error, boolean>
    const b = a(
      // Let's mock our dependencies.
      pipe(
        $has.singleton(TagFoo, { bar: () => taskEither.of('foobar') }),
        $has.upsertAt(TagBar, () => ioEither.of(true)),
      ),
    )

Changed

  • Replace struct type with Struct.
  • Rename GeneratorL module to Yield.
  • Use cause property to record wrapped errors (inspired by TC39).

Deprecated

  • Deprecate struct (use Struct instead).
  • Deprecate GeneratorL module (use Yield instead).

Fixed

  • Decode from Json and then from the given codec in the get function of the Redis module.