Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Commit

Permalink
remove /schema dependency (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Aug 19, 2023
1 parent 993cf58 commit 7c99a42
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 159 deletions.
5 changes: 5 additions & 0 deletions .changeset/grumpy-camels-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/match": minor
---

remove /schema dependency
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ console.log(match({ age: 4 })) // "4 is too young"

### `not` patterns

`not` lets you match on everything but a specific value or Schema.
`not` lets you match on everything but a specific value.

```ts
import * as Match from "@effect/match"
Expand Down Expand Up @@ -129,7 +129,7 @@ A Matcher that _might_ match a value. Returns an [Option](https://github.com/fp-

```ts
import * as Match from "@effect/match"
import * as E from "@effect/data/Either";
import * as E from "@effect/data/Either"
import { pipe } from "@effect/data/Function"

// type Either<L, R> = { _tag: "Right", right: R } | { _tag: "Left", left: L }
Expand All @@ -149,7 +149,7 @@ A Matcher that marks the end of the matching process and checks if all possible

```ts
import * as Match from "@effect/match"
import * as E from "@effect/data/Either";
import * as E from "@effect/data/Either"
import { pipe } from "@effect/data/Function"

// type Either<L, R> = { _tag: "Right", right: R } | { _tag: "Left", left: L }
Expand All @@ -158,7 +158,6 @@ const result = pipe(
Match.when({ _tag: "Right" }, (_) => _.right),
Match.exhaustive, // TypeError! { _tag: "left", left: never } is not assignable to never
)

```

### `orElse`
Expand All @@ -179,7 +178,6 @@ console.log(match("hello")) // "I literally do not understand"
console.log(match("hi")) // "hello"
```


### `either`

A Matcher that _might_ match a value. Returns an [Either](https://github.com/fp-ts/core/blob/main/guides/Either.md) in the shape of `Either<NoMatchResult, MatchResult>`.
Expand All @@ -188,7 +186,6 @@ A Matcher that _might_ match a value. Returns an [Either](https://github.com/fp-
import * as Match from "@effect/match"
import { pipe } from "@effect/data/Function"


const match = pipe(
Match.type<string>(),
Match.when("hi", (_) => "hello"),
Expand Down
72 changes: 22 additions & 50 deletions docs/modules/index.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Added in v1.0.0
- [orElseAbsurd](#orelseabsurd)
- [model](#model)
- [Matcher (type alias)](#matcher-type-alias)
- [SafeSchema (interface)](#safeschema-interface)
- [SafeRefinement (interface)](#saferefinement-interface)
- [predicates](#predicates)
- [any](#any)
- [bigint](#bigint)
Expand All @@ -50,13 +50,11 @@ Added in v1.0.0
- [null](#null)
- [number](#number)
- [record](#record)
- [safe](#safe)
- [string](#string)
- [undefined](#undefined)
- [unsafe](#unsafe)
- [utils](#utils)
- [SafeSchemaId](#safeschemaid)
- [SafeSchemaId (type alias)](#safeschemaid-type-alias)
- [SafeRefinementId](#saferefinementid)
- [SafeRefinementId (type alias)](#saferefinementid-type-alias)

---

Expand Down Expand Up @@ -130,7 +128,7 @@ Added in v1.0.0
export declare const not: <
R,
const P extends PatternPrimitive<R> | PatternBase<R>,
Fn extends (_: Exclude<R, ExtractMatch<R, SafeSchemaR<PredToSchema<P>>>>) => unknown
Fn extends (_: Exclude<R, ExtractMatch<R, SafeRefinementR<ToSafeRefinement<P>>>>) => unknown
>(
pattern: P,
f: Fn
Expand Down Expand Up @@ -211,8 +209,8 @@ export declare const when: <
self: Matcher<I, F, R, A, Pr>
) => Matcher<
I,
AddWithout<F, SafeSchemaR<PredToSchema<P>>>,
ApplyFilters<I, AddWithout<F, SafeSchemaR<PredToSchema<P>>>>,
AddWithout<F, SafeRefinementR<ToSafeRefinement<P>>>,
ApplyFilters<I, AddWithout<F, SafeRefinementR<ToSafeRefinement<P>>>>,
A | ReturnType<Fn>,
Pr
>
Expand All @@ -235,8 +233,8 @@ export declare const whenAnd: <
self: Matcher<I, F, R, A, Pr>
) => Matcher<
I,
AddWithout<F, SafeSchemaR<PredToSchema<UnionToIntersection<P[number]>>>>,
ApplyFilters<I, AddWithout<F, SafeSchemaR<PredToSchema<UnionToIntersection<P[number]>>>>>,
AddWithout<F, SafeRefinementR<ToSafeRefinement<UnionToIntersection<P[number]>>>>,
ApplyFilters<I, AddWithout<F, SafeRefinementR<ToSafeRefinement<UnionToIntersection<P[number]>>>>>,
A | ReturnType<Fn>,
Pr
>
Expand All @@ -259,8 +257,8 @@ export declare const whenOr: <
self: Matcher<I, F, R, A, Pr>
) => Matcher<
I,
AddWithout<F, SafeSchemaR<PredToSchema<P[number]>>>,
ApplyFilters<I, AddWithout<F, SafeSchemaR<PredToSchema<P[number]>>>>,
AddWithout<F, SafeRefinementR<ToSafeRefinement<P[number]>>>,
ApplyFilters<I, AddWithout<F, SafeRefinementR<ToSafeRefinement<P[number]>>>>,
A | ReturnType<Fn>,
Pr
>
Expand Down Expand Up @@ -395,13 +393,13 @@ export type Matcher<Input, Filters, RemainingApplied, Result, Provided> =
Added in v1.0.0
## SafeSchema (interface)
## SafeRefinement (interface)
**Signature**
```ts
export interface SafeSchema<A, R = A> {
readonly [SafeSchemaId]: SafeSchemaId
export interface SafeRefinement<A, R = A> {
readonly [SafeRefinementId]: SafeRefinementId
readonly _A: A
readonly _R: R
}
Expand All @@ -416,7 +414,7 @@ Added in v1.0.0
**Signature**

```ts
export declare const any: SafeSchema<unknown, any>
export declare const any: SafeRefinement<unknown, any>
```

Added in v1.0.0
Expand Down Expand Up @@ -468,7 +466,7 @@ Added in v1.0.0
```ts
export declare const instanceOf: <A extends abstract new (...args: any) => any>(
constructor: A
) => SafeSchema<InstanceType<A>, never>
) => SafeRefinement<InstanceType<A>, never>
```

Added in v1.0.0
Expand All @@ -480,7 +478,7 @@ Added in v1.0.0
```ts
export declare const instanceOfUnsafe: <A extends abstract new (...args: any) => any>(
constructor: A
) => SafeSchema<InstanceType<A>, InstanceType<A>>
) => SafeRefinement<InstanceType<A>, InstanceType<A>>
```

Added in v1.0.0
Expand All @@ -490,7 +488,7 @@ Added in v1.0.0
**Signature**

```ts
export declare const is: <Literals extends readonly LiteralValue[]>(
export declare const is: <Literals extends readonly (string | number | bigint | boolean | null)[]>(
...literals: Literals
) => Refinement<unknown, Literals[number]>
```
Expand All @@ -502,7 +500,7 @@ Added in v1.0.0
**Signature**

```ts
export declare const nonEmptyString: SafeSchema<string, never>
export declare const nonEmptyString: SafeRefinement<string, never>
```

Added in v1.0.0
Expand Down Expand Up @@ -537,19 +535,6 @@ export declare const record: Refinement<unknown, { [k: string]: any; [k: symbol]

Added in v1.0.0

## safe

Use a schema as a predicate, marking it **safe**. Safe means **it does not**
contain refinements that could make the pattern not match.

**Signature**

```ts
export declare const safe: <A>(schema: S.Schema<A, A>) => SafeSchema<A, A>
```

Added in v1.0.0

## string

**Signature**
Expand All @@ -570,37 +555,24 @@ export declare const undefined: Refinement<unknown, undefined>

Added in v1.0.0

## unsafe

Use a schema as a predicate, marking it **unsafe**. Unsafe means it contains
refinements that could make the pattern not match.

**Signature**

```ts
export declare const unsafe: <A>(schema: S.Schema<A, A>) => SafeSchema<A, never>
```

Added in v1.0.0

# utils

## SafeSchemaId
## SafeRefinementId

**Signature**

```ts
export declare const SafeSchemaId: typeof SafeSchemaId
export declare const SafeRefinementId: typeof SafeRefinementId
```

Added in v1.0.0

## SafeSchemaId (type alias)
## SafeRefinementId (type alias)

**Signature**

```ts
export type SafeSchemaId = typeof SafeSchemaId
export type SafeRefinementId = typeof SafeRefinementId
```
Added in v1.0.0
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
}
},
"peerDependencies": {
"@effect/data": "^0.17.1",
"@effect/schema": "^0.33.0"
"@effect/data": "^0.17.1"
},
"devDependencies": {
"@babel/cli": "^7.22.9",
Expand All @@ -70,7 +69,6 @@
"@effect/docgen": "^0.1.2",
"@effect/eslint-plugin": "^0.1.2",
"@effect/language-service": "^0.0.19",
"@effect/schema": "^0.33.0",
"@types/chai": "^4.3.5",
"@types/node": "^20.4.6",
"@typescript-eslint/eslint-plugin": "^6.2.1",
Expand Down
33 changes: 0 additions & 33 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7c99a42

Please sign in to comment.