How to use the fp-ts.either.map 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 devexperts / swagger-codegen-ts / src / language / typescript / 3.0 / index.ts View on Github external
serializeDocument => (
		documents: Dictionary,
		options: SerializeOptions = {},
	): Either =>
		pipe(
			documents,
			record.collect(serializeDocument),
			sequenceEither,
			either.map(e =>
				mapFS(fragment(e), content => format(content, options.prettierConfig || defaultPrettierConfig)),
			),
		),
);
github devexperts / swagger-codegen-ts / src / language / typescript / 2.0 / serializers / schema-object.ts View on Github external
option.map(properties =>
						pipe(
							properties,
							record.collect((name, value) => {
								const isRequired = pipe(
									schema.required,
									option.map(includes(name)),
									option.getOrElse(constFalse),
								);
								return pipe(
									serializeSchemaObjectWithRecursion(from, value, false),
									either.map(getSerializedOptionPropertyType(name, isRequired)),
								);
							}),
							sequenceEither,
							either.map(s => intercalateSerializedTypes(serializedType(';', ',', [], []), s)),
							either.map(getSerializedObjectType(from.name)),
							either.map(getSerializedRecursiveType(from, shouldTrackRecursion)),
						),
					),
github devexperts / swagger-codegen-ts / src / language / typescript / 2.0 / serializers / responses-definitions-object.ts View on Github external
export const serializeResponsesDefinitionsObject = (
	from: Ref,
	responsesDefinitionsObject: ResponsesDefinitionsObject,
): Either =>
	pipe(
		responsesDefinitionsObject,
		record.collect((name, parameterObject) =>
			pipe(
				from,
				addPathParts(name),
				either.chain(from => serializeResponse(from, parameterObject)),
			),
		),
		sequenceEither,
		either.map(content => directory('responses', content)),
	);
github devexperts / swagger-codegen-ts / src / language / typescript / 3.0 / serializers / responses-object.ts View on Github external
ReferenceObjectCodec.is(r)
						? pipe(
								fromString(r.$ref),
								either.mapLeft(
									() => new Error(`Invalid ${r.$ref} for ResponsesObject'c code "${code}"`),
								),
								either.map(getSerializedRefType(from)),
								some,
						  )
						: serializeResponseObject(from, r),
				),
			),
		),
		array.compact,
		sequenceEither,
		either.map(uniqSerializedTypesByTypeAndIO),
	);
	return pipe(
		serializedResponses,
		either.map(serializedResponses => {
			if (serializedResponses.length === 0) {
				return SERIALIZED_VOID_TYPE;
			}
			const combined = intercalateSerializedTypes(serializedType('|', ',', [], []), serializedResponses);
			const isUnion = serializedResponses.length > 1;
			return serializedType(
				combined.type,
				isUnion ? `union([${combined.io}])` : combined.io,
				concatIfL(isUnion, combined.dependencies, () => [serializedDependency('union', 'io-ts')]),
				[],
			);
		}),
github devexperts / swagger-codegen-ts / src / language / typescript / 3.0 / serializers / parameter-object.ts View on Github external
either.chain(schema => {
			if (ReferenceObjectCodec.is(schema)) {
				return pipe(fromString(schema.$ref), either.map(getSerializedRefType(from)));
			} else {
				return pipe(schema, serializeSchemaObject(from));
			}
		}),
		either.map(fromSerializedType(isRequired(parameterObject))),
github devexperts / swagger-codegen-ts / src / language / typescript / common / bundled / utils.ts View on Github external
import { fromString } from '../../../../utils/ref';
import { pipe } from 'fp-ts/lib/pipeable';
import { either } from 'fp-ts';
import { fromRef } from '../../../../utils/fs';

export const utilsRef = fromString('#/utils/utils');

const utils = `
`;

export const utilsFile = pipe(
	utilsRef,
	either.map(ref => fromRef(ref, '.ts', utils)),
);
github devexperts / swagger-codegen-ts / src / language / typescript / 3.0 / serializers / schema-object.ts View on Github external
}

	switch (schemaObject.type) {
		case 'string':
		case 'boolean':
		case 'integer':
		case 'number': {
			return serializePrimitive(from, schemaObject);
		}
		case 'array': {
			const { items } = schemaObject;
			const serialized = ReferenceObjectCodec.is(items)
				? pipe(
						fromString(items.$ref),
						mapLeft(() => new Error(`Unable to serialize SchemaObjeft array items ref "${items.$ref}"`)),
						either.map(getSerializedRefType(from)),
				  )
				: pipe(items, serializeSchemaObjectWithRecursion(from, false, undefined));
			return pipe(serialized, either.map(getSerializedArrayType(name)));
		}
		case 'object': {
			const additionalProperties = pipe(
				schemaObject.additionalProperties,
				option.filter(isAllowedAdditionalProperties),
				option.map(additionalProperties => {
					if (ReferenceObjectCodec.is(additionalProperties)) {
						return pipe(
							additionalProperties.$ref,
							fromString,
							mapLeft(
								() =>
									new Error(
github devexperts / swagger-codegen-ts / src / language / typescript / sketch-121 / serializers / objects / style.ts View on Github external
option.map(fills =>
			pipe(
				fills,
				nonEmptyArray.map(fill => serializeGradient(fill.gradient)),
				nonEmptyArray.nonEmptyArray.sequence(either.either),
				either.map(gradients => `backgroundImage: '${gradients.join(', ')}'`),
			),
		),
github devexperts / swagger-codegen-ts / src / language / typescript / 3.0 / serializers / schema-object.ts View on Github external
option.map(includes(name)),
								option.getOrElse(constFalse),
							);

							if (ReferenceObjectCodec.is(property)) {
								return pipe(
									property.$ref,
									fromString,
									mapLeft(
										() =>
											new Error(
												`Unable to serialize SchemaObject property "${name}" ref "${property.$ref}"`,
											),
									),
									either.map(getSerializedRefType(from)),
									either.map(getSerializedOptionPropertyType(name, isRequired)),
								);
							} else {
								return pipe(
									property,
									serializeSchemaObjectWithRecursion(from, false, undefined),
									either.map(getSerializedOptionPropertyType(name, isRequired)),
								);
							}
						}),
						sequenceEither,
github devexperts / swagger-codegen-ts / src / language / typescript / 2.0 / serializers / definitions-object.ts View on Github external
export const serializeDefinitions = (from: Ref, definitions: DefinitionsObject): Either =>
	pipe(
		definitions,
		record.collect((name, definition) =>
			pipe(
				from,
				addPathParts(name),
				either.chain(from => serializeDefinition(from, name, definition)),
			),
		),
		sequenceEither,
		either.map(serialized => directory(DEFINITIONS_DIRECTORY, serialized)),
	);