Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
add tagStartsWith (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Sep 5, 2023
1 parent 1d0c320 commit 14e0676
Show file tree
Hide file tree
Showing 12 changed files with 34,560 additions and 837 deletions.
5 changes: 5 additions & 0 deletions .changeset/modern-ligers-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/match": patch
---

add discriminatorStartsWith & tagStartsWith
79 changes: 0 additions & 79 deletions docs/modules/ADT.ts.md

This file was deleted.

57 changes: 57 additions & 0 deletions docs/modules/SafeRefinement.ts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: SafeRefinement.ts
nav_order: 2
parent: Modules
---

## SafeRefinement overview

Added in v1.0.0

---

<h2 class="text-delta">Table of contents</h2>

- [model](#model)
- [SafeRefinement (interface)](#saferefinement-interface)
- [utils](#utils)
- [SafeRefinementId](#saferefinementid)
- [SafeRefinementId (type alias)](#saferefinementid-type-alias)

---

# model

## SafeRefinement (interface)

**Signature**

```ts
export interface SafeRefinement<A, R = A> {
readonly [SafeRefinementId]: (a: A) => R
}
```

Added in v1.0.0

# utils

## SafeRefinementId

**Signature**

```ts
export declare const SafeRefinementId: typeof SafeRefinementId
```
Added in v1.0.0
## SafeRefinementId (type alias)
**Signature**
```ts
export type SafeRefinementId = typeof SafeRefinementId
```
Added in v1.0.0
41 changes: 0 additions & 41 deletions docs/modules/TaggedEnum.ts.md

This file was deleted.

213 changes: 213 additions & 0 deletions docs/modules/Types.ts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
---
title: Types.ts
nav_order: 3
parent: Modules
---

## Types overview

Added in v1.0.0

---

<h2 class="text-delta">Table of contents</h2>

- [utils](#utils)
- [AddOnly (type alias)](#addonly-type-alias)
- [AddWithout (type alias)](#addwithout-type-alias)
- [ApplyFilters (type alias)](#applyfilters-type-alias)
- [ArrayToIntersection (type alias)](#arraytointersection-type-alias)
- [ExtractMatch (type alias)](#extractmatch-type-alias)
- [NotMatch (type alias)](#notmatch-type-alias)
- [Only (interface)](#only-interface)
- [PForExclude (type alias)](#pforexclude-type-alias)
- [PForMatch (type alias)](#pformatch-type-alias)
- [PatternBase (type alias)](#patternbase-type-alias)
- [PatternPrimitive (type alias)](#patternprimitive-type-alias)
- [Tags (type alias)](#tags-type-alias)
- [WhenMatch (type alias)](#whenmatch-type-alias)
- [Without (interface)](#without-interface)

---

# utils

## AddOnly (type alias)

**Signature**

```ts
export type AddOnly<A, X> = [A] extends [Without<infer WX>]
? [X] extends [WX]
? never
: Only<X>
: [A] extends [Only<infer OX>]
? [X] extends [OX]
? Only<X>
: never
: never
```
Added in v1.0.0
## AddWithout (type alias)
**Signature**
```ts
export type AddWithout<A, X> = [A] extends [Without<infer WX>]
? Without<X | WX>
: [A] extends [Only<infer OX>]
? Only<Exclude<OX, X>>
: never
```
Added in v1.0.0
## ApplyFilters (type alias)
**Signature**
```ts
export type ApplyFilters<I, A> = A extends Only<infer X> ? X : A extends Without<infer X> ? Exclude<I, X> : never
```
Added in v1.0.0
## ArrayToIntersection (type alias)
**Signature**
```ts
export type ArrayToIntersection<A extends ReadonlyArray<any>> = UnionToIntersection<A[number]>
```
Added in v1.0.0
## ExtractMatch (type alias)
**Signature**
```ts
export type ExtractMatch<I, P> = [ExtractAndNarrow<I, P>] extends [infer EI] ? EI : never
```
Added in v1.0.0
## NotMatch (type alias)
**Signature**
```ts
export type NotMatch<R, P> = Exclude<R, ExtractMatch<R, PForExclude<P>>>
```
Added in v1.0.0
## Only (interface)
**Signature**
```ts
export interface Only<X> {
readonly _tag: 'Only'
readonly _X: X
}
```

Added in v1.0.0

## PForExclude (type alias)

**Signature**

```ts
export type PForExclude<P> = SafeRefinementR<ToSafeRefinement<P>>
```
Added in v1.0.0
## PForMatch (type alias)
**Signature**
```ts
export type PForMatch<P> = SafeRefinementP<ResolvePred<P>>
```
Added in v1.0.0
## PatternBase (type alias)
**Signature**
```ts
export type PatternBase<A> = A extends ReadonlyArray<infer _T>
? ReadonlyArray<any> | PatternPrimitive<A>
: A extends Record<string, any>
? Partial<{
[K in keyof A]: PatternPrimitive<A[K] & {}> | PatternBase<A[K] & {}>
}>
: never
```
Added in v1.0.0
## PatternPrimitive (type alias)
**Signature**
```ts
export type PatternPrimitive<A> = PredicateA<A> | A | SafeRefinement<any>
```
Added in v1.0.0
## Tags (type alias)
**Signature**
```ts
export type Tags<D extends string, P> = P extends Record<D, infer X> ? X : never
```
Added in v1.0.0
## WhenMatch (type alias)
**Signature**
```ts
export type WhenMatch<R, P> =
// check for any
[0] extends [1 & R]
? PForMatch<P>
: P extends SafeRefinement<infer SP, never>
? SP
: P extends Refinement<infer _R, infer RP>
? // try to narrow refinement
[Extract<R, RP>] extends [infer X]
? [X] extends [never]
? // fallback to original refinement
RP
: X
: never
: P extends PredicateA<infer PP>
? PP
: ExtractMatch<R, PForMatch<P>>
```
Added in v1.0.0
## Without (interface)
**Signature**
```ts
export interface Without<X> {
readonly _tag: 'Without'
readonly _X: X
}
```

Added in v1.0.0
Loading

0 comments on commit 14e0676

Please sign in to comment.