import { AlgebraicType } from './algebraic_type.ts'; export type ResultAlgebraicType< T extends AlgebraicType = AlgebraicType, E extends AlgebraicType = AlgebraicType, > = { tag: 'Sum'; value: { variants: [ { name: 'ok'; algebraicType: T }, { name: 'err'; algebraicType: E }, ]; }; }; export const Result: { getAlgebraicType< T extends AlgebraicType = AlgebraicType, E extends AlgebraicType = AlgebraicType, >( okType: T, errType: E ): ResultAlgebraicType; } = { getAlgebraicType< T extends AlgebraicType = AlgebraicType, E extends AlgebraicType = AlgebraicType, >(okType: T, errType: E): ResultAlgebraicType { return AlgebraicType.Sum({ variants: [ { name: 'ok', algebraicType: okType }, { name: 'err', algebraicType: errType }, ], }); }, };