How to use the fp-ts/lib/pipeable.pipe function in fp-ts

To help you get started, we’ve selected a few fp-ts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gcanti / io-ts / test / helpers.ts View on Github external
export function assertFailure(codec: t.Any, value: unknown, errors: Array): void {
  const result = codec.decode(value)
  pipe(
    result,
    fold(
      () => {
        assert.deepStrictEqual(PathReporter.report(result), errors)
      },
      /* istanbul ignore next */
      () => {
        throw new Error(`${result} is not a left`)
      }
    )
  )
}
github devexperts / remote-data-ts / src / __tests__ / remote-data.spec.ts View on Github external
it('success', () => {
				expect(
					pipe(
						success(1),
						toEither(initialL, pendingL),
					),
				).toEqual(right(1));
			});
		});
github gcanti / docs-ts / src / core.ts View on Github external
function writeMarkdownFiles(files: Array): AppEff {
  const cleanOut: AppEff = C =>
    pipe(
      C.log(`Writing markdown...`),
      TE.chain(() => C.debug(`Clean up docs folder: deleting ${outPattern}...`)),
      TE.chain(() => C.clean(outPattern))
    )

  return pipe(
    cleanOut,
    RTE.chain(() => writeFiles(files))
  )
}
github devexperts / swagger-codegen-ts / src / language / typescript / 2.0 / serializers / schema-object.ts View on Github external
option.map(additionalProperties =>
					pipe(
						serializeSchemaObjectWithRecursion(from, additionalProperties, false),
						either.map(getSerializedDictionaryType()),
						either.map(getSerializedRecursiveType(from, shouldTrackRecursion)),
					),
				),
github ryu1kn / vscode-text-marker / src / lib / text-location-registry.ts View on Github external
findPreviousOccurence(editorId: string, range: FlatRange): O.Option {
        return pipe(
            this.findDecorationIdAndRanges(editorId, range),
            O.map(([_, ranges]) => {
                const newIndex = ranges.findIndex(this.isPointingRange(range)) - 1;
                return ranges[newIndex < 0 ? ranges.length - 1 : newIndex];
            })
        );
    }
github mikearnaldi / matechs-effect / src / example / Main.ts View on Github external
import * as E from "../index";
import * as P from "./Printer";
import * as C from "./Counter";
import * as T from "./Tracer";

import { Do } from "fp-ts-contrib/lib/Do";
import { pipe } from "fp-ts/lib/pipeable";
import { withControllerSpan, withTracer } from "./Tracer";

export const module = pipe(
  E.noEnv,
  E.mergeEnv(P.printer),
  E.mergeEnv(C.counter),
  E.mergeEnv(T.tracer),
  E.mergeEnv(T.tracerFactoryDummy)
);

export const program = withTracer(
  E.provide(C.counterState())(
    Do(E.effectMonad)
      .bind("start", C.currentCount())
      .do(withControllerSpan("controller-a")(C.count()))
      .do(withControllerSpan("controller-b")(C.count()))
      .bind("end", C.currentCount())
      .doL(({ start, end }) => P.print(`done - ${start} <-> ${end}`))
      .done()
github mikearnaldi / matechs-effect / packages / effect / src / original / support / dequeue.ts View on Github external
() =>
        pipe(
          this.back,
          l.reverse,
          l.catac(
            (h, t) => some([h, new DequeueImpl(t, nil)] as const),
            () => none
          )
        )
    );
github devexperts / swagger-codegen-ts / src / language / typescript / asyncapi-2.0.0 / serializers / schema-object.ts View on Github external
const serializeProperties = (
	from: Ref,
	schemaObject: ObjectSchemaObject,
	shouldTrackRecursion: boolean,
	name?: string,
): Option> =>
	pipe(
		schemaObject.properties,
		option.map(properties =>
			pipe(
				properties,
				record.collect((name, property) => {
					const isRequired = pipe(
						schemaObject.required,
						option.map(required => required.has(name)),
						option.getOrElse(constFalse),
					);

					const serialized = ReferenceObjectCodec.is(property)
						? pipe(fromString(property.$ref), either.map(getSerializedRefType(from)))
						: serializeSchemaObjectWithRecursion(from, property, false);

					return pipe(serialized, either.map(getSerializedOptionPropertyType(name, isRequired)));
github stoplightio / prism / packages / http / src / validator / validators / body.ts View on Github external
function deserializeAndValidate(content: IMediaTypeContent, schema: JSONSchema, target: string) {
  const encodings = get(content, 'encodings', []);
  const encodedUriParams = splitUriParams(target);

  return pipe(
    validateAgainstReservedCharacters(encodedUriParams, encodings),
    E.map(decodeUriEntities),
    E.map(decodedUriEntities => deserializeFormBody(schema, encodings, decodedUriEntities)),
    E.chain(deserialised =>
      pipe(
        validateAgainstSchema(deserialised, schema, true),
        E.fromOption(() => deserialised),
        E.swap
      )
    )
  );
}
github devexperts / swagger-codegen-ts / src / language / typescript / sketch-121 / serializers / objects / style.ts View on Github external
),
	);
	const backgroundImage = pipe(
		fills,
		option.chain(nonEmptyArray.filter(fill => fill.fillType === 'Gradient')),
		option.map(fills =>
			pipe(
				fills,
				nonEmptyArray.map(fill => serializeGradient(fill.gradient)),
				nonEmptyArray.nonEmptyArray.sequence(either.either),
				either.map(gradients => `backgroundImage: '${gradients.join(', ')}'`),
			),
		),
		sequenceOptionEither,
	);
	const backgroundBlendMode = pipe(
		fills,
		option.map(array.filterMap(fill => option.fromEither(getBackgroundBlendMode(fill.contextSettings.blendMode)))),
		option.chain(array.last),
		option.filter(mode => mode !== 'normal'),
		option.map(mode => `backgroundBlendMode: '${mode}'`),
	);
	const mixBlendMode = pipe(
		style.contextSettings,
		option.chain(settings => option.fromEither(getMixBlendMode(settings.blendMode))),
		option.filter(mode => mode !== 'normal'),
		option.map(mode => `mixBlendMode: '${mode}'`),
	);
	const opacity = pipe(
		style.contextSettings,
		option.map(settings => settings.opacity),
		option.filter(n => n !== 1),