Hyperlinkv0.8.0-beta.28

SchemaAST

SchemaAST.toEncodedconsteffect/SchemaAST.ts:3438
(ast: AST): AST

Returns the encoded (wire-format) AST by flipping and then stripping encodings.

Details

Equivalent to toType(flip(ast)). This gives you the AST that describes the shape of the serialized/encoded data.

  • Memoized: same input reference → same output reference.

Example (Getting the encoded AST)

import { Schema, SchemaAST } from "effect"

const schema = Schema.NumberFromString
const encodedAst = SchemaAST.toEncoded(schema.ast)
console.log(encodedAst._tag) // "String"
transformingtoTypeflip
export const toEncoded = memoize((ast: AST): AST => {
  return toType(flip(ast))
})
Referenced by 5 symbols