Repository: dubzzz/fast-check
Pull request #1727 (2021-04-12 14:11:35)

🚚 Move frequency arbitraries into /arbitrary
<!-- Why is this PR for? -->
<!-- Describe the reason why you opened this PR or give a link towards the associated issue. -->

## In a nutshell

❌ New feature
❌ Fix an issue
❌ Documentation improvement
✔️ Other: *moving files*

(✔️: yes, ❌: no)

## Potential impacts

No impact is expected as IDE fail to import the right paths with auto-imports different from root.
Non-root import changed for frequency, oneof, option


codesandbox[bot]: This pull request is automatically built and testable in [CodeSandbox](https://codesandbox.io).

  To see build info of the built libraries, click [here](https://ci.codesandbox.io/status/dubzzz/fast-check/pr/1727/builds/118808) or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 7d1cf1669c70d81606efd21d422c238723c62751:

|Sandbox| Source |
|--|--|
|[Vanilla](https://codesandbox.io/s/vanilla-hwi59)| Configuration |

codecov[bot]: # [Codecov](https://codecov.io/gh/dubzzz/fast-check/pull/1727?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) Report
> Merging [#1727](https://codecov.io/gh/dubzzz/fast-check/pull/1727?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) (7d1cf16) into [main](https://codecov.io/gh/dubzzz/fast-check/commit/b1e9611ff57a270fee2d4fc0710298264eab608e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) (b1e9611) will **decrease** coverage by `0.08%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/dubzzz/fast-check/pull/1727/graphs/tree.svg?width=650&height=150&src=pr&token=fRi2fJN730&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN)](https://codecov.io/gh/dubzzz/fast-check/pull/1727?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN)

```diff
@@            Coverage Diff             @@
##             main    #1727      +/-   ##
==========================================
- Coverage   96.59%   96.51%   -0.09%     
==========================================
  Files         108      109       +1     
  Lines        3585     3586       +1     
  Branches      710      710              
==========================================
- Hits         3463     3461       -2     
- Misses        118      121       +3     
  Partials        4        4              
```

| Flag | Coverage Δ | |
|---|---|---|
| unit-tests | `96.51% <100.00%> (-0.09%)` | :arrow_down: |
| unit-tests-10.x-Linux | `96.51% <100.00%> (+<0.01%)` | :arrow_up: |
| unit-tests-12.x-Linux | `?` | |
| unit-tests-14.x-Linux | `?` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/dubzzz/fast-check/pull/1727?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) | Coverage Δ | |
|---|---|---|
| [src/arbitrary/\_internals/helpers/DepthContext.ts](https://codecov.io/gh/dubzzz/fast-check/pull/1727/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#diff-c3JjL2FyYml0cmFyeS9faW50ZXJuYWxzL2hlbHBlcnMvRGVwdGhDb250ZXh0LnRz) | `91.66% <ø> (ø)` | |
| [src/arbitrary/\_internals/FrequencyArbitrary.ts](https://codecov.io/gh/dubzzz/fast-check/pull/1727/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#diff-c3JjL2FyYml0cmFyeS9faW50ZXJuYWxzL0ZyZXF1ZW5jeUFyYml0cmFyeS50cw==) | `80.00% <100.00%> (ø)` | |
| [src/arbitrary/frequency.ts](https://codecov.io/gh/dubzzz/fast-check/pull/1727/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#diff-c3JjL2FyYml0cmFyeS9mcmVxdWVuY3kudHM=) | `100.00% <100.00%> (ø)` | |
| [src/arbitrary/oneof.ts](https://codecov.io/gh/dubzzz/fast-check/pull/1727/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#diff-c3JjL2FyYml0cmFyeS9vbmVvZi50cw==) | `100.00% <100.00%> (ø)` | |
| [src/arbitrary/option.ts](https://codecov.io/gh/dubzzz/fast-check/pull/1727/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#diff-c3JjL2FyYml0cmFyeS9vcHRpb24udHM=) | `100.00% <100.00%> (ø)` | |
| [src/check/arbitrary/HostArbitrary.ts](https://codecov.io/gh/dubzzz/fast-check/pull/1727/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#diff-c3JjL2NoZWNrL2FyYml0cmFyeS9Ib3N0QXJiaXRyYXJ5LnRz) | `100.00% <100.00%> (ø)` | |
| [src/check/arbitrary/IpArbitrary.ts](https://codecov.io/gh/dubzzz/fast-check/pull/1727/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#diff-c3JjL2NoZWNrL2FyYml0cmFyeS9JcEFyYml0cmFyeS50cw==) | `100.00% <100.00%> (ø)` | |
| [src/check/arbitrary/LoremArbitrary.ts](https://codecov.io/gh/dubzzz/fast-check/pull/1727/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#diff-c3JjL2NoZWNrL2FyYml0cmFyeS9Mb3JlbUFyYml0cmFyeS50cw==) | `100.00% <100.00%> (ø)` | |
| [src/check/arbitrary/ObjectArbitrary.ts](https://codecov.io/gh/dubzzz/fast-check/pull/1727/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#diff-c3JjL2NoZWNrL2FyYml0cmFyeS9PYmplY3RBcmJpdHJhcnkudHM=) | `97.34% <100.00%> (ø)` | |
| [src/check/arbitrary/RecordArbitrary.ts](https://codecov.io/gh/dubzzz/fast-check/pull/1727/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN#diff-c3JjL2NoZWNrL2FyYml0cmFyeS9SZWNvcmRBcmJpdHJhcnkudHM=) | `98.11% <100.00%> (ø)` | |
| ... and [6 more](https://codecov.io/gh/dubzzz/fast-check/pull/1727/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/dubzzz/fast-check/pull/1727?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/dubzzz/fast-check/pull/1727?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN). Last update [b1e9611...7d1cf16](https://codecov.io/gh/dubzzz/fast-check/pull/1727?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nicolas+DUBIEN).


Patch:
diff --git a/src/check/arbitrary/FrequencyArbitrary.ts b/src/arbitrary/_internals/FrequencyArbitrary.ts
similarity index 58%
rename from src/check/arbitrary/FrequencyArbitrary.ts
rename to src/arbitrary/_internals/FrequencyArbitrary.ts
index 7710dafe..6d925604 100644
--- a/src/check/arbitrary/FrequencyArbitrary.ts
+++ b/src/arbitrary/_internals/FrequencyArbitrary.ts
@@ -1,57 +1,22 @@
 import { Random } from '../../random/generator/Random';
 import { Stream } from '../../stream/Stream';
-import { Arbitrary } from './definition/Arbitrary';
-import { convertFromNext, convertToNext } from './definition/Converters';
-import { NextArbitrary } from './definition/NextArbitrary';
-import { NextValue } from './definition/NextValue';
+import { Arbitrary } from '../../check/arbitrary/definition/Arbitrary';
+import { convertFromNext, convertToNext } from '../../check/arbitrary/definition/Converters';
+import { NextArbitrary } from '../../check/arbitrary/definition/NextArbitrary';
+import { NextValue } from '../../check/arbitrary/definition/NextValue';
 import { DepthContext, getDepthContextFor } from './helpers/DepthContext';
 
-/**
- * Conjonction of a weight and an arbitrary used by {@link frequency}
- * in order to generate values
- *
- * @remarks Since 1.18.0
- * @public
- */
-export interface WeightedArbitrary<T> {
-  /**
-   * Weight to be applied when selecting which arbitrary should be used
-   * @remarks Since 0.0.7
-   */
-  weight: number;
-  /**
-   * Instance of Arbitrary
-   * @remarks Since 0.0.7
-   */
-  arbitrary: Arbitrary<T>;
-}
-
-/** @internal */
-interface WeightedNextArbitrary<T> {
-  weight: number;
-  arbitrary: NextArbitrary<T>;
-}
-
-/** @internal */
-type FrequencyArbitraryContext<T> = {
-  selectedIndex: number;
-  originalBias: number | undefined;
-  originalContext: unknown;
-  clonedMrngForFallbackFirst: Random | null;
-  cachedGeneratedForFirst?: NextValue<T>;
-};
-
 /** @internal */
 export class FrequencyArbitrary<T> extends NextArbitrary<T> {
-  readonly summedWarbs: WeightedNextArbitrary<T>[];
+  readonly summedWarbs: _WeightedNextArbitrary<T>[];
   readonly totalWeight: number;
 
-  static from<T>(warbs: WeightedArbitrary<T>[], constraints: FrequencyContraints, label: string): Arbitrary<T> {
+  static from<T>(warbs: _WeightedArbitrary<T>[], constraints: _FrequencyContraints, label: string): Arbitrary<T> {
     if (warbs.length === 0) {
       throw new Error(`${label} expects at least one weigthed arbitrary`);
     }
     let totalWeight = 0;
-    const warbsNext: WeightedNextArbitrary<T>[] = [];
+    const warbsNext: _WeightedNextArbitrary<T>[] = [];
     for (let idx = 0; idx !== warbs.length; ++idx) {
       const currentArbitrary = warbs[idx].arbitrary;
       if (currentArbitrary === undefined) {
@@ -76,8 +41,8 @@ export class FrequencyArbitrary<T> extends NextArbitrary<T> {
   }
 
   private constructor(
-    readonly warbs: WeightedNextArbitrary<T>[],
-    readonly constraints: FrequencyContraints,
+    readonly warbs: _WeightedNextArbitrary<T>[],
+    readonly constraints: _FrequencyContraints,
     readonly context: DepthContext
   ) {
     super();
@@ -110,7 +75,7 @@ export class FrequencyArbitrary<T> extends NextArbitrary<T> {
 
   shrink(value: T, context?: unknown): Stream<NextValue<T>> {
     if (context !== undefined) {
-      const safeContext = context as FrequencyArbitraryContext<T>;
+      const safeContext = context as _FrequencyArbitraryContext<T>;
       const selectedIndex = safeContext.selectedIndex;
       const originalBias = safeContext.originalBias;
       const originalArbitrary = this.summedWarbs[selectedIndex].arbitrary;
@@ -165,7 +130,7 @@ export class FrequencyArbitrary<T> extends NextArbitrary<T> {
     clonedMrngForFallbackFirst: Random | null,
     biasFactor: number | undefined
   ): NextValue<T> {
-    const context: FrequencyArbitraryContext<T> = {
+    const context: _FrequencyArbitraryContext<T> = {
       selectedIndex: idx,
       originalBias: biasFactor,
       originalContext: value.context,
@@ -210,113 +175,31 @@ export class FrequencyArbitrary<T> extends NextArbitrary<T> {
   }
 }
 
-/**
- * Infer the type of the Arbitrary produced by {@link frequency}
- * given the type of the source arbitraries
- *
- * @remarks Since 2.2.0
- * @public
- */
-export type FrequencyValue<Ts extends WeightedArbitrary<unknown>[]> = {
-  [K in keyof Ts]: Ts[K] extends WeightedArbitrary<infer U> ? U : never;
-}[number];
+/** @internal */
+interface _WeightedArbitrary<T> {
+  weight: number;
+  arbitrary: Arbitrary<T>;
+}
+
+/** @internal */
+interface _WeightedNextArbitrary<T> {
+  weight: number;
+  arbitrary: NextArbitrary<T>;
+}
 
-/**
- * Constraints to be applied on {@link frequency}
- * @remarks Since 2.14.0
- * @public
- */
-export type FrequencyContraints = {
-  /**
-   * When set to true, the shrinker of frequency will try to check if the first arbitrary
-   * could have been used to discover an issue. It allows to shrink trees.
-   *
-   * Warning: First arbitrary must be the one resulting in the smallest structures
-   * for usages in deep tree-like structures.
-   *
-   * Warning: First arbitrary will not be used if its weight is set to zero.
-   *
-   * @remarks Since 2.14.0
-   */
+/** @internal */
+type _FrequencyContraints = {
   withCrossShrink?: boolean;
-  /**
-   * While going deeper and deeper within a recursive structure (see {@link letrec}),
-   * this factor will be used to increase the probability to generate instances
-   * of the first passed arbitrary.
-   *
-   * Example of values: 0.1 (small impact as depth increases), 0.5, 1 (huge impact as depth increases).
-   *
-   * Warning: First arbitrary will not be used if its weight is set to zero.
-   *
-   * @remarks Since 2.14.0
-   */
   depthFactor?: number;
-  /**
-   * Maximal authorized depth.
-   * Once this depth has been reached only the first arbitrary will be used.
-   *
-   * Warning: Contrary to others, first arbitrary will be used even if its weight is set to zero.
-   *
-   * @remarks Since 2.14.0
-   */
   maxDepth?: number;
-  /**
-   * Depth identifier can be used to share the current depth between several instances.
-   *
-   * By default, if not specified, each instance of frequency will have its own depth.
-   * In other words: you can have depth=1 in one while you have depth=100 in another one.
-   *
-   * @remarks Since 2.14.0
-   */
   depthIdentifier?: string;
 };
 
-/**
- * @internal
- */
-function isFrequencyContraints(
-  param: FrequencyContraints | WeightedArbitrary<unknown> | undefined
-): param is FrequencyContraints {
-  return param != null && typeof param === 'object' && !('arbitrary' in param);
-}
-
-/**
- * For one of the values generated by `...warbs` - the probability of selecting the ith warb is of `warb[i].weight / sum(warb[j].weight)`
- *
- * **WARNING**: It expects at least one (Arbitrary, weight)
- *
- * @param warbs - (Arbitrary, weight)s that might be called to produce a value
- *
- * @remarks Since 0.0.7
- * @public
- */
-function frequency<Ts extends WeightedArbitrary<unknown>[]>(...warbs: Ts): Arbitrary<FrequencyValue<Ts>>;
-/**
- * For one of the values generated by `...warbs` - the probability of selecting the ith warb is of `warb[i].weight / sum(warb[j].weight)`
- *
- * **WARNING**: It expects at least one (Arbitrary, weight)
- *
- * @param constraints - Constraints to be applied when generating the values
- * @param warbs - (Arbitrary, weight)s that might be called to produce a value
- *
- * @remarks Since 0.0.7
- * @public
- */
-function frequency<Ts extends WeightedArbitrary<unknown>[]>(
-  constraints: FrequencyContraints,
-  ...warbs: Ts
-): Arbitrary<FrequencyValue<Ts>>;
-function frequency<Ts extends WeightedArbitrary<unknown>[]>(
-  ...args: [...Ts] | [FrequencyContraints, ...Ts]
-): Arbitrary<FrequencyValue<Ts>> {
-  // TODO With TypeScript 4.0 it will be possible to properly define typings for `frequency(...arbs, constraints)`
-  const label = 'fc.frequency';
-  const constraints = args[0];
-  if (isFrequencyContraints(constraints)) {
-    return FrequencyArbitrary.from(args.slice(1) as WeightedArbitrary<FrequencyValue<Ts>>[], constraints, label);
-  }
-
-  return FrequencyArbitrary.from(args as WeightedArbitrary<FrequencyValue<Ts>>[], {}, label);
-}
-
-export { frequency };
+/** @internal */
+type _FrequencyArbitraryContext<T> = {
+  selectedIndex: number;
+  originalBias: number | undefined;
+  originalContext: unknown;
+  clonedMrngForFallbackFirst: Random | null;
+  cachedGeneratedForFirst?: NextValue<T>;
+};
diff --git a/src/check/arbitrary/helpers/DepthContext.ts b/src/arbitrary/_internals/helpers/DepthContext.ts
similarity index 100%
rename from src/check/arbitrary/helpers/DepthContext.ts
rename to src/arbitrary/_internals/helpers/DepthContext.ts
diff --git a/src/arbitrary/frequency.ts b/src/arbitrary/frequency.ts
new file mode 100644
index 00000000..8feb0a86
--- /dev/null
+++ b/src/arbitrary/frequency.ts
@@ -0,0 +1,130 @@
+import { Arbitrary } from '../check/arbitrary/definition/Arbitrary';
+import { FrequencyArbitrary } from './_internals/FrequencyArbitrary';
+
+/**
+ * Conjonction of a weight and an arbitrary used by {@link frequency}
+ * in order to generate values
+ *
+ * @remarks Since 1.18.0
+ * @public
+ */
+export interface WeightedArbitrary<T> {
+  /**
+   * Weight to be applied when selecting which arbitrary should be used
+   * @remarks Since 0.0.7
+   */
+  weight: number;
+  /**
+   * Instance of Arbitrary
+   * @remarks Since 0.0.7
+   */
+  arbitrary: Arbitrary<T>;
+}
+
+/**
+ * Infer the type of the Arbitrary produced by {@link frequency}
+ * given the type of the source arbitraries
+ *
+ * @remarks Since 2.2.0
+ * @public
+ */
+export type FrequencyValue<Ts extends WeightedArbitrary<unknown>[]> = {
+  [K in keyof Ts]: Ts[K] extends WeightedArbitrary<infer U> ? U : never;
+}[number];
+
+/**
+ * Constraints to be applied on {@link frequency}
+ * @remarks Since 2.14.0
+ * @public
+ */
+export type FrequencyContraints = {
+  /**
+   * When set to true, the shrinker of frequency will try to check if the first arbitrary
+   * could have been used to discover an issue. It allows to shrink trees.
+   *
+   * Warning: First arbitrary must be the one resulting in the smallest structures
+   * for usages in deep tree-like structures.
+   *
+   * Warning: First arbitrary will not be used if its weight is set to zero.
+   *
+   * @remarks Since 2.14.0
+   */
+  withCrossShrink?: boolean;
+  /**
+   * While going deeper and deeper within a recursive structure (see {@link letrec}),
+   * this factor will be used to increase the probability to generate instances
+   * of the first passed arbitrary.
+   *
+   * Example of values: 0.1 (small impact as depth increases), 0.5, 1 (huge impact as depth increases).
+   *
+   * Warning: First arbitrary will not be used if its weight is set to zero.
+   *
+   * @remarks Since 2.14.0
+   */
+  depthFactor?: number;
+  /**
+   * Maximal authorized depth.
+   * Once this depth has been reached only the first arbitrary will be used.
+   *
+   * Warning: Contrary to others, first arbitrary will be used even if its weight is set to zero.
+   *
+   * @remarks Since 2.14.0
+   */
+  maxDepth?: number;
+  /**
+   * Depth identifier can be used to share the current depth between several instances.
+   *
+   * By default, if not specified, each instance of frequency will have its own depth.
+   * In other words: you can have depth=1 in one while you have depth=100 in another one.
+   *
+   * @remarks Since 2.14.0
+   */
+  depthIdentifier?: string;
+};
+
+/** @internal */
+function isFrequencyContraints(
+  param: FrequencyContraints | WeightedArbitrary<unknown> | undefined
+): param is FrequencyContraints {
+  return param != null && typeof param === 'object' && !('arbitrary' in param);
+}
+
+/**
+ * For one of the values generated by `...warbs` - the probability of selecting the ith warb is of `warb[i].weight / sum(warb[j].weight)`
+ *
+ * **WARNING**: It expects at least one (Arbitrary, weight)
+ *
+ * @param warbs - (Arbitrary, weight)s that might be called to produce a value
+ *
+ * @remarks Since 0.0.7
+ * @public
+ */
+function frequency<Ts extends WeightedArbitrary<unknown>[]>(...warbs: Ts): Arbitrary<FrequencyValue<Ts>>;
+/**
+ * For one of the values generated by `...warbs` - the probability of selecting the ith warb is of `warb[i].weight / sum(warb[j].weight)`
+ *
+ * **WARNING**: It expects at least one (Arbitrary, weight)
+ *
+ * @param constraints - Constraints to be applied when generating the values
+ * @param warbs - (Arbitrary, weight)s that might be called to produce a value
+ *
+ * @remarks Since 0.0.7
+ * @public
+ */
+function frequency<Ts extends WeightedArbitrary<unknown>[]>(
+  constraints: FrequencyContraints,
+  ...warbs: Ts
+): Arbitrary<FrequencyValue<Ts>>;
+function frequency<Ts extends WeightedArbitrary<unknown>[]>(
+  ...args: [...Ts] | [FrequencyContraints, ...Ts]
+): Arbitrary<FrequencyValue<Ts>> {
+  // TODO With TypeScript 4.0 it will be possible to properly define typings for `frequency(...arbs, constraints)`
+  const label = 'fc.frequency';
+  const constraints = args[0];
+  if (isFrequencyContraints(constraints)) {
+    return FrequencyArbitrary.from(args.slice(1) as WeightedArbitrary<FrequencyValue<Ts>>[], constraints, label);
+  }
+
+  return FrequencyArbitrary.from(args as WeightedArbitrary<FrequencyValue<Ts>>[], {}, label);
+}
+export { frequency };
diff --git a/src/check/arbitrary/OneOfArbitrary.ts b/src/arbitrary/oneof.ts
similarity index 96%
rename from src/check/arbitrary/OneOfArbitrary.ts
rename to src/arbitrary/oneof.ts
index be892e75..5a411d2c 100644
--- a/src/check/arbitrary/OneOfArbitrary.ts
+++ b/src/arbitrary/oneof.ts
@@ -1,5 +1,5 @@
-import { Arbitrary } from './definition/Arbitrary';
-import { FrequencyArbitrary } from './FrequencyArbitrary';
+import { Arbitrary } from '../check/arbitrary/definition/Arbitrary';
+import { FrequencyArbitrary } from './_internals/FrequencyArbitrary';
 
 /**
  * Infer the type of the Arbitrary produced by {@link oneof}
@@ -98,5 +98,4 @@ function oneof<Ts extends Arbitrary<unknown>[]>(
   const weightedArbs = (args as Arbitrary<OneOfValue<Ts>>[]).map((arbitrary) => ({ arbitrary, weight: 1 }));
   return FrequencyArbitrary.from(weightedArbs, {}, 'fc.oneof');
 }
-
 export { oneof };
diff --git a/src/check/arbitrary/OptionArbitrary.ts b/src/arbitrary/option.ts
similarity index 92%
rename from src/check/arbitrary/OptionArbitrary.ts
rename to src/arbitrary/option.ts
index c7371253..20bf08c9 100644
--- a/src/check/arbitrary/OptionArbitrary.ts
+++ b/src/arbitrary/option.ts
@@ -1,7 +1,7 @@
-import { FrequencyContraints } from '../../fast-check-default';
-import { constant } from './ConstantArbitrary';
-import { Arbitrary } from './definition/Arbitrary';
-import { FrequencyArbitrary } from './FrequencyArbitrary';
+import { FrequencyContraints } from '../fast-check-default';
+import { constant } from '../check/arbitrary/ConstantArbitrary';
+import { Arbitrary } from '../check/arbitrary/definition/Arbitrary';
+import { FrequencyArbitrary } from './_internals/FrequencyArbitrary';
 
 /**
  * Constraints to be applied on {@link option}
@@ -101,5 +101,4 @@ function option<T, TNil>(arb: Arbitrary<T>, rawConstraints?: number | OptionCons
   };
   return FrequencyArbitrary.from(weightedArbs, frequencyConstraints, 'fc.option');
 }
-
 export { option };
diff --git a/src/check/arbitrary/HostArbitrary.ts b/src/check/arbitrary/HostArbitrary.ts
index 1223abb7..a8f097b0 100644
--- a/src/check/arbitrary/HostArbitrary.ts
+++ b/src/check/arbitrary/HostArbitrary.ts
@@ -4,7 +4,7 @@ import {
   buildLowerAlphaArb,
   buildLowerAlphaNumericArb,
 } from './helpers/SpecificCharacterRange';
-import { option } from './OptionArbitrary';
+import { option } from '../../arbitrary/option';
 import { stringOf } from './StringArbitrary';
 import { tuple } from './TupleArbitrary';
 import { Arbitrary } from './definition/Arbitrary';
diff --git a/src/check/arbitrary/IpArbitrary.ts b/src/check/arbitrary/IpArbitrary.ts
index 594772fa..6303d4a6 100644
--- a/src/check/arbitrary/IpArbitrary.ts
+++ b/src/check/arbitrary/IpArbitrary.ts
@@ -2,7 +2,7 @@ import { array } from '../../arbitrary/array';
 import { constantFrom } from './ConstantArbitrary';
 import { Arbitrary } from './definition/Arbitrary';
 import { nat } from '../../arbitrary/nat';
-import { oneof } from './OneOfArbitrary';
+import { oneof } from '../../arbitrary/oneof';
 import { hexaString } from './StringArbitrary';
 import { tuple } from './TupleArbitrary';
 
diff --git a/src/check/arbitrary/LoremArbitrary.ts b/src/check/arbitrary/LoremArbitrary.ts
index 57e05e71..bc6488cb 100644
--- a/src/check/arbitrary/LoremArbitrary.ts
+++ b/src/check/arbitrary/LoremArbitrary.ts
@@ -1,7 +1,7 @@
 import { array } from '../../arbitrary/array';
 import { constant } from './ConstantArbitrary';
 import { Arbitrary } from './definition/Arbitrary';
-import { frequency } from './FrequencyArbitrary';
+import { frequency } from '../../arbitrary/frequency';
 
 /**
  * Constraints to be applied on {@link lorem}
diff --git a/src/check/arbitrary/ObjectArbitrary.ts b/src/check/arbitrary/ObjectArbitrary.ts
index ee1dd279..e377b260 100644
--- a/src/check/arbitrary/ObjectArbitrary.ts
+++ b/src/check/arbitrary/ObjectArbitrary.ts
@@ -6,10 +6,10 @@ import { boolean } from './BooleanArbitrary';
 import { constant } from './ConstantArbitrary';
 import { dictionary, toObject } from './DictionaryArbitrary';
 import { double } from './FloatingPointArbitrary';
-import { frequency } from './FrequencyArbitrary';
+import { frequency } from '../../arbitrary/frequency';
 import { maxSafeInteger } from '../../arbitrary/maxSafeInteger';
 import { memo, Memo } from './MemoArbitrary';
-import { oneof } from './OneOfArbitrary';
+import { oneof } from '../../arbitrary/oneof';
 import { set } from '../../arbitrary/set';
 import { string, unicodeString } from './StringArbitrary';
 import { tuple } from './TupleArbitrary';
diff --git a/src/check/arbitrary/RecordArbitrary.ts b/src/check/arbitrary/RecordArbitrary.ts
index 1174db5b..8733d48a 100644
--- a/src/check/arbitrary/RecordArbitrary.ts
+++ b/src/check/arbitrary/RecordArbitrary.ts
@@ -1,6 +1,6 @@
 import { Arbitrary } from './definition/Arbitrary';
 
-import { option } from './OptionArbitrary';
+import { option } from '../../arbitrary/option';
 import { genericTuple } from './TupleArbitrary';
 
 /**
diff --git a/src/check/arbitrary/WebArbitrary.ts b/src/check/arbitrary/WebArbitrary.ts
index cf2ffa4f..0f104bd8 100644
--- a/src/check/arbitrary/WebArbitrary.ts
+++ b/src/check/arbitrary/WebArbitrary.ts
@@ -5,8 +5,8 @@ import { buildAlphaNumericPercentArb } from './helpers/SpecificCharacterRange';
 import { domain, hostUserInfo } from './HostArbitrary';
 import { nat } from '../../arbitrary/nat';
 import { ipV4, ipV4Extended, ipV6 } from './IpArbitrary';
-import { oneof } from './OneOfArbitrary';
-import { option } from './OptionArbitrary';
+import { oneof } from '../../arbitrary/oneof';
+import { option } from '../../arbitrary/option';
 import { stringOf } from './StringArbitrary';
 import { tuple } from './TupleArbitrary';
 import { Arbitrary } from './definition/Arbitrary';
diff --git a/src/check/arbitrary/helpers/SpecificCharacterRange.ts b/src/check/arbitrary/helpers/SpecificCharacterRange.ts
index 0c84f555..64924632 100644
--- a/src/check/arbitrary/helpers/SpecificCharacterRange.ts
+++ b/src/check/arbitrary/helpers/SpecificCharacterRange.ts
@@ -1,6 +1,6 @@
 import { fullUnicode } from '../CharacterArbitrary';
 import { Arbitrary } from '../definition/Arbitrary';
-import { frequency } from '../FrequencyArbitrary';
+import { frequency } from '../../../arbitrary/frequency';
 import { mapToConstant } from '../MapToConstantArbitrary';
 
 /** @internal */
diff --git a/src/check/model/commands/CommandsArbitrary.ts b/src/check/model/commands/CommandsArbitrary.ts
index b7405002..debf7ab1 100644
--- a/src/check/model/commands/CommandsArbitrary.ts
+++ b/src/check/model/commands/CommandsArbitrary.ts
@@ -4,7 +4,7 @@ import { Arbitrary } from '../../arbitrary/definition/Arbitrary';
 import { ArbitraryWithContextualShrink } from '../../arbitrary/definition/ArbitraryWithContextualShrink';
 import { Shrinkable } from '../../arbitrary/definition/Shrinkable';
 import { nat } from '../../../arbitrary/nat';
-import { oneof } from '../../arbitrary/OneOfArbitrary';
+import { oneof } from '../../../arbitrary/oneof';
 import { AsyncCommand } from '../command/AsyncCommand';
 import { Command } from '../command/Command';
 import { ICommand } from '../command/ICommand';
diff --git a/src/fast-check-default.ts b/src/fast-check-default.ts
index 1234934c..b8e58fe9 100644
--- a/src/fast-check-default.ts
+++ b/src/fast-check-default.ts
@@ -37,12 +37,7 @@ import { Shrinkable } from './check/arbitrary/definition/Shrinkable';
 import { dictionary } from './check/arbitrary/DictionaryArbitrary';
 import { emailAddress } from './check/arbitrary/EmailArbitrary';
 import { double, float, DoubleConstraints, FloatConstraints } from './check/arbitrary/FloatingPointArbitrary';
-import {
-  frequency,
-  WeightedArbitrary,
-  FrequencyValue,
-  FrequencyContraints,
-} from './check/arbitrary/FrequencyArbitrary';
+import { frequency, WeightedArbitrary, FrequencyValue, FrequencyContraints } from './arbitrary/frequency';
 import { compareBooleanFunc, compareFunc, func } from './check/arbitrary/FunctionArbitrary';
 import { domain } from './check/arbitrary/HostArbitrary';
 import { integer, IntegerConstraints } from './arbitrary/integer';
@@ -65,8 +60,8 @@ import {
   unicodeJson,
   unicodeJsonObject,
 } from './check/arbitrary/ObjectArbitrary';
-import { oneof, OneOfValue, OneOfConstraints } from './check/arbitrary/OneOfArbitrary';
-import { option, OptionConstraints } from './check/arbitrary/OptionArbitrary';
+import { oneof, OneOfValue, OneOfConstraints } from './arbitrary/oneof';
+import { option, OptionConstraints } from './arbitrary/option';
 import { record, RecordConstraints, RecordValue } from './check/arbitrary/RecordArbitrary';
 import { set, SetConstraints } from './arbitrary/set';
 import { infiniteStream } from './check/arbitrary/StreamArbitrary';


Test patch:
diff --git a/test/unit/check/arbitrary/FrequencyArbitrary.itest.spec.ts b/test/unit/arbitrary/FrequencyArbitrary.itest.spec.ts
similarity index 91%
rename from test/unit/check/arbitrary/FrequencyArbitrary.itest.spec.ts
rename to test/unit/arbitrary/FrequencyArbitrary.itest.spec.ts
index b38b4a6d..d1cb00ea 100644
--- a/test/unit/check/arbitrary/FrequencyArbitrary.itest.spec.ts
+++ b/test/unit/arbitrary/FrequencyArbitrary.itest.spec.ts
@@ -1,14 +1,14 @@
-import * as fc from '../../../../lib/fast-check';
+import * as fc from '../../../lib/fast-check';
 
-import { frequency } from '../../../../src/check/arbitrary/FrequencyArbitrary';
-import { integer } from '../../../../src/arbitrary/integer';
-import { constant } from '../../../../src/check/arbitrary/ConstantArbitrary';
+import { frequency } from '../../../src/arbitrary/frequency';
+import { integer } from '../../../src/arbitrary/integer';
+import { constant } from '../../../src/check/arbitrary/ConstantArbitrary';
 
-import * as genericHelper from './generic/GenericArbitraryHelper';
+import * as genericHelper from '../check/arbitrary/generic/GenericArbitraryHelper';
 
 import { mocked } from 'ts-jest/utils';
-import * as DepthContextMock from '../../../../src/check/arbitrary/helpers/DepthContext';
-jest.mock('../../../../src/check/arbitrary/helpers/DepthContext');
+import * as DepthContextMock from '../../../src/arbitrary/_internals/helpers/DepthContext';
+jest.mock('../../../src/arbitrary/_internals/helpers/DepthContext');
 
 const depthContextData: Record<string, DepthContextMock.DepthContext> = {};
 
diff --git a/test/unit/check/arbitrary/FrequencyArbitrary.utest.spec.ts b/test/unit/arbitrary/FrequencyArbitrary.utest.spec.ts
similarity index 96%
rename from test/unit/check/arbitrary/FrequencyArbitrary.utest.spec.ts
rename to test/unit/arbitrary/FrequencyArbitrary.utest.spec.ts
index ea681456..ea30f71b 100644
--- a/test/unit/check/arbitrary/FrequencyArbitrary.utest.spec.ts
+++ b/test/unit/arbitrary/FrequencyArbitrary.utest.spec.ts
@@ -1,11 +1,11 @@
-import * as fc from '../../../../lib/fast-check';
+import * as fc from '../../../lib/fast-check';
 
-import { Arbitrary } from '../../../../src/check/arbitrary/definition/Arbitrary';
-import { Shrinkable } from '../../../../src/check/arbitrary/definition/Shrinkable';
-import { frequency } from '../../../../src/check/arbitrary/FrequencyArbitrary';
-import { Random } from '../../../../src/random/generator/Random';
+import { Arbitrary } from '../../../src/check/arbitrary/definition/Arbitrary';
+import { Shrinkable } from '../../../src/check/arbitrary/definition/Shrinkable';
+import { frequency } from '../../../src/arbitrary/frequency';
+import { Random } from '../../../src/random/generator/Random';
 
-import * as stubArb from '../../stubs/arbitraries';
+import * as stubArb from '../stubs/arbitraries';
 
 const frequencyValidInputsArb = fc
   .tuple(
diff --git a/test/unit/check/arbitrary/OneOfArbitrary.itest.spec.ts b/test/unit/arbitrary/OneOfArbitrary.itest.spec.ts
similarity index 75%
rename from test/unit/check/arbitrary/OneOfArbitrary.itest.spec.ts
rename to test/unit/arbitrary/OneOfArbitrary.itest.spec.ts
index 9a133f82..4729f509 100644
--- a/test/unit/check/arbitrary/OneOfArbitrary.itest.spec.ts
+++ b/test/unit/arbitrary/OneOfArbitrary.itest.spec.ts
@@ -1,16 +1,16 @@
-import * as fc from '../../../../lib/fast-check';
+import * as fc from '../../../lib/fast-check';
 
-import { Arbitrary } from '../../../../src/check/arbitrary/definition/Arbitrary';
-import { Shrinkable } from '../../../../src/check/arbitrary/definition/Shrinkable';
-import { constant } from '../../../../src/check/arbitrary/ConstantArbitrary';
-import { integer } from '../../../../src/arbitrary/integer';
-import { oneof } from '../../../../src/check/arbitrary/OneOfArbitrary';
-import { Random } from '../../../../src/random/generator/Random';
-import { stream } from '../../../../src/stream/Stream';
+import { Arbitrary } from '../../../src/check/arbitrary/definition/Arbitrary';
+import { Shrinkable } from '../../../src/check/arbitrary/definition/Shrinkable';
+import { constant } from '../../../src/check/arbitrary/ConstantArbitrary';
+import { integer } from '../../../src/arbitrary/integer';
+import { oneof } from '../../../src/arbitrary/oneof';
+import { Random } from '../../../src/random/generator/Random';
+import { stream } from '../../../src/stream/Stream';
 
-import * as genericHelper from './generic/GenericArbitraryHelper';
+import * as genericHelper from '../check//arbitrary/generic/GenericArbitraryHelper';
 
-import * as stubRng from '../../stubs/generators';
+import * as stubRng from '../stubs/generators';
 
 class CustomArbitrary extends Arbitrary<number> {
   constructor(readonly value: number) {
diff --git a/test/unit/check/arbitrary/OneOfArbitrary.utest.spec.ts b/test/unit/arbitrary/OneOfArbitrary.utest.spec.ts
similarity index 84%
rename from test/unit/check/arbitrary/OneOfArbitrary.utest.spec.ts
rename to test/unit/arbitrary/OneOfArbitrary.utest.spec.ts
index beb2bebc..27eee63b 100644
--- a/test/unit/check/arbitrary/OneOfArbitrary.utest.spec.ts
+++ b/test/unit/arbitrary/OneOfArbitrary.utest.spec.ts
@@ -1,10 +1,10 @@
 import { mocked } from 'ts-jest/utils';
 
-import { constant } from '../../../../src/check/arbitrary/ConstantArbitrary';
-import { oneof, OneOfConstraints } from '../../../../src/check/arbitrary/OneOfArbitrary';
+import { constant } from '../../../src/check/arbitrary/ConstantArbitrary';
+import { oneof, OneOfConstraints } from '../../../src/arbitrary/oneof';
 
-import * as FrequencyArbitraryMock from '../../../../src/check/arbitrary/FrequencyArbitrary';
-jest.mock('../../../../src/check/arbitrary/FrequencyArbitrary');
+import * as FrequencyArbitraryMock from '../../../src/arbitrary/_internals/FrequencyArbitrary';
+jest.mock('../../../src/arbitrary/_internals/FrequencyArbitrary');
 
 describe('OneOfArbitrary', () => {
   describe('oneof', () => {
diff --git a/test/unit/check/arbitrary/OptionArbitrary.spec.ts b/test/unit/arbitrary/OptionArbitrary.spec.ts
similarity index 84%
rename from test/unit/check/arbitrary/OptionArbitrary.spec.ts
rename to test/unit/arbitrary/OptionArbitrary.spec.ts
index 6a6e9e0e..e49d501a 100644
--- a/test/unit/check/arbitrary/OptionArbitrary.spec.ts
+++ b/test/unit/arbitrary/OptionArbitrary.spec.ts
@@ -1,11 +1,11 @@
 import * as prand from 'pure-rand';
-import * as fc from '../../../../lib/fast-check';
+import * as fc from '../../../lib/fast-check';
 
-import { option } from '../../../../src/check/arbitrary/OptionArbitrary';
-import { Random } from '../../../../src/random/generator/Random';
+import { option } from '../../../src/arbitrary/option';
+import { Random } from '../../../src/random/generator/Random';
 
-import * as stubArb from '../../stubs/arbitraries';
-import * as stubRng from '../../stubs/generators';
+import * as stubArb from '../stubs/arbitraries';
+import * as stubRng from '../stubs/generators';
 
 describe('OptionArbitrary', () => {
   describe('option', () => {
diff --git a/test/unit/check/arbitrary/ObjectArbitrary.spec.ts b/test/unit/check/arbitrary/ObjectArbitrary.spec.ts
index 63818d96..5645425f 100644
--- a/test/unit/check/arbitrary/ObjectArbitrary.spec.ts
+++ b/test/unit/check/arbitrary/ObjectArbitrary.spec.ts
@@ -2,7 +2,7 @@ import * as prand from 'pure-rand';
 import * as fc from '../../../../lib/fast-check';
 
 import { constant } from '../../../../src/check/arbitrary/ConstantArbitrary';
-import { oneof } from '../../../../src/check/arbitrary/OneOfArbitrary';
+import { oneof } from '../../../../src/arbitrary/oneof';
 import {
   anything,
   object,