export interface Encoder<O, A> {
readonly encode: (a: A) => O
}
Example
An encoder representing a nullable value
import * as E from 'io-ts/Encoder'
export function nullable<O, A>(or: E.Encoder<O, A>): E.Encoder<null | O, null | A> {
return {
encode: (a) => (a === null ? null : or.encode(a))
}
}