(type: Type, value: Schema.Codec<Value>)
| 897 | thunk: RepresentationSchema |
| 898 | }) |
| 899 | function makeValueSchema<Type extends string, Value>(type: Type, value: Schema.Codec<Value>) { |
| 900 | return value.pipe( |
| 901 | Schema.encodeTo(Schema.Struct({ type: Schema.tag(type), value }), { |
| 902 | decode: SchemaGetter.transform((encoded: { readonly type: Type; readonly value: Value }) => encoded.value), |
| 903 | encode: SchemaGetter.transform((value: Value) => ({ type, value })) |
| 904 | }) |
| 905 | ) |
| 906 | } |
| 907 | const StringValueCodec = makeValueSchema("string", Schema.String) |
| 908 | const NumberValueCodec = makeValueSchema("number", Schema.Number) |
| 909 | const LiteralSchema = Schema.Struct({ |
no test coverage detected