github Effect-TS/effect effect@3.11.6

Patch Changes

  • #4118 662d1ce Thanks @gcanti! - Allow the transformation created by the Class API to be annotated on all its components: the type side, the transformation itself, and the encoded side.

    Example

    import { Schema, SchemaAST } from "effect"
    
    class A extends Schema.Class<A>("A")(
      {
        a: Schema.NonEmptyString
      },
      [
        { identifier: "TypeID" }, // annotations for the type side
        { identifier: "TransformationID" }, // annotations for the the transformation itself
        { identifier: "EncodedID" } // annotations for the the encoded side
      ]
    ) {}
    
    console.log(SchemaAST.getIdentifierAnnotation(A.ast.to)) // Some("TypeID")
    console.log(SchemaAST.getIdentifierAnnotation(A.ast)) // Some("TransformationID")
    console.log(SchemaAST.getIdentifierAnnotation(A.ast.from)) // Some("EncodedID")
    
    A.make({ a: "" })
    /*
    ParseError: TypeID
    └─ ["a"]
       └─ NonEmptyString
          └─ Predicate refinement failure
             └─ Expected NonEmptyString, actual ""
    */
    
    Schema.encodeSync(A)({ a: "" })
    /*
    ParseError: TransformationID
    └─ Type side transformation failure
       └─ TypeID
          └─ ["a"]
             └─ NonEmptyString
                └─ Predicate refinement failure
                   └─ Expected NonEmptyString, actual ""
    */
  • #4126 31c62d8 Thanks @gcanti! - Rewrite the Arbitrary compiler from scratch, closes #2312

Don't miss a new effect release

NewReleases is sending notifications on new releases.