Skip to content

Conversation

@gcanti
Copy link
Contributor

@gcanti gcanti commented Mar 25, 2025

Before

import { Arbitrary, Schema } from "effect"

const schema = Schema.Int.annotations({
  arbitrary: (_, ctx) => (fc) => {
    console.log("context: ", ctx)
    return fc.integer()
  }
}).pipe(Schema.greaterThan(0), Schema.lessThan(10))

Arbitrary.make(schema)
// No output ❌

After

import { Arbitrary, Schema } from "effect"

const schema = Schema.Int.annotations({
  arbitrary: (_, ctx) => (fc) => {
    console.log("context: ", ctx)
    return fc.integer()
  }
}).pipe(Schema.greaterThan(0), Schema.lessThan(10))

Arbitrary.make(schema)
/*
context:  {
  maxDepth: 2,
  constraints: {
    _tag: 'NumberConstraints',
    constraints: { min: 0, minExcluded: true, max: 10, maxExcluded: true },
    isInteger: true
  }
}
*/

@changeset-bot
Copy link

changeset-bot bot commented Mar 25, 2025

🦋 Changeset detected

Latest commit: 28a6494

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 32 packages
Name Type
effect Patch
@effect/cli Patch
@effect/cluster Patch
@effect/experimental Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/platform Patch
@effect/printer-ansi Patch
@effect/printer Patch
@effect/rpc Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-drizzle Patch
@effect/sql-kysely Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/sql Patch
@effect/typeclass Patch
@effect/vitest Patch
@effect/ai Patch
@effect/ai-anthropic Patch
@effect/ai-openai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gcanti gcanti added the bug Something isn't working label Mar 25, 2025
@gcanti gcanti merged commit f87991b into main Mar 25, 2025
11 checks passed
@gcanti gcanti deleted the schema-arbitrary-refactoring branch March 25, 2025 15:51
@github-project-automation github-project-automation bot moved this from Discussion Ongoing to Done in PR Backlog Mar 25, 2025
@github-actions github-actions bot mentioned this pull request Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working schema: Arbitrary schema

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants