import { AlgebraicType } from './algebraic_type.ts'; export type OptionAlgebraicType = { tag: 'Sum'; value: { variants: [ { name: 'some'; algebraicType: T }, { name: 'none'; algebraicType: { tag: 'Product'; value: { elements: [] } }; }, ]; }; }; export const Option: { getAlgebraicType( innerType: T ): OptionAlgebraicType; } = { getAlgebraicType( innerType: T ): OptionAlgebraicType { return AlgebraicType.Sum({ variants: [ { name: 'some', algebraicType: innerType }, { name: 'none', algebraicType: AlgebraicType.Product({ elements: [] }), }, ], }); }, };