Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

add Serializable module #609

Merged
merged 39 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8a7f73c
add Serializable module
tim-smart Nov 29, 2023
a91f269
docs
tim-smart Nov 29, 2023
ae554fe
allow From types in Serializable
tim-smart Nov 29, 2023
7d231b5
seperate WithResult
tim-smart Nov 29, 2023
7b47e92
add serializable / deserialize functions
tim-smart Nov 29, 2023
20c2cfa
update serialize signature
tim-smart Nov 29, 2023
5c2b03c
extend Request
Nov 29, 2023
98d4e9a
add Schema for Cause
tim-smart Nov 30, 2023
bbae836
add Exit schema
tim-smart Nov 30, 2023
4b91650
changesets
tim-smart Nov 30, 2023
305b8e8
replace SerializableWithResult with SerializableWithExit
tim-smart Nov 30, 2023
6017e7c
add Serializable tests
tim-smart Nov 30, 2023
9d568dd
update doc categories
tim-smart Nov 30, 2023
8ef8d4a
keep failure and success schemas separate
tim-smart Nov 30, 2023
b06e365
traverse Cause with ParseResult
Nov 30, 2023
6cdc60f
add generics to Serializable
Nov 30, 2023
887f784
toggle types
Nov 30, 2023
4991033
rename fiberId to fiberId, fiberIdFromSelf to FiberIdFromSelf (standard)
gcanti Nov 30, 2023
77d015b
move new test files
gcanti Nov 30, 2023
8130105
add basic FiberId test files
gcanti Nov 30, 2023
8fecf68
move tests files
gcanti Nov 30, 2023
6c3ae8a
chore
gcanti Nov 30, 2023
51c2724
remove some casts
gcanti Nov 30, 2023
6c73266
add OptionFrom, EitherFrom
gcanti Nov 30, 2023
4e5b0a5
move to calls to the right
gcanti Nov 30, 2023
27272b1
use transform for FiberId
tim-smart Nov 30, 2023
b590a5e
move Serializable generics right
tim-smart Dec 1, 2023
b648c07
simplify fiberIdArbitrary
gcanti Dec 3, 2023
e8be3c0
simplify causeArbitrary
gcanti Dec 3, 2023
7f1aa04
refactor exitArbitrary
gcanti Dec 3, 2023
cbeca3b
update docs
gcanti Dec 3, 2023
f1d79b6
more tests
gcanti Dec 3, 2023
78fc076
remove causeTraverse
gcanti Dec 3, 2023
7bd36db
fix Request error type
tim-smart Dec 3, 2023
3d9cbb5
docs
tim-smart Dec 3, 2023
f7ece0b
add optional defect schema to exit / cause
tim-smart Dec 4, 2023
0992baa
docs
tim-smart Dec 4, 2023
dcf703a
chore
gcanti Dec 4, 2023
a080797
typo
gcanti Dec 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilly-parrots-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/schema": patch
---

add Serializable module
5 changes: 5 additions & 0 deletions .changeset/late-ladybugs-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/schema": patch
---

add FiberId schema
5 changes: 5 additions & 0 deletions .changeset/purple-laws-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/schema": patch
---

add Exit schema
5 changes: 5 additions & 0 deletions .changeset/witty-ladybugs-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/schema": patch
---

add Cause schema
210 changes: 190 additions & 20 deletions docs/modules/Schema.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ Added in v1.0.0
- [BigDecimal transformations](#bigdecimal-transformations)
- [clampBigDecimal](#clampbigdecimal)
- [negateBigDecimal](#negatebigdecimal)
- [Cause](#cause)
- [CauseFrom (type alias)](#causefrom-type-alias)
- [cause](#cause-1)
- [causeFromSelf](#causefromself)
- [Chunk transformations](#chunk-transformations)
- [chunk](#chunk)
- [chunkFromSelf](#chunkfromself)
Expand All @@ -55,6 +59,14 @@ Added in v1.0.0
- [EitherFrom (type alias)](#eitherfrom-type-alias)
- [either](#either)
- [eitherFromSelf](#eitherfromself)
- [Exit](#exit)
- [ExitFrom (type alias)](#exitfrom-type-alias)
- [exit](#exit-1)
- [exitFromSelf](#exitfromself)
- [FiberId](#fiberid)
- [FiberId](#fiberid-1)
- [FiberIdFrom (type alias)](#fiberidfrom-type-alias)
- [FiberIdFromSelf](#fiberidfromself)
- [Option transformations](#option-transformations)
- [OptionFrom (type alias)](#optionfrom-type-alias)
- [option](#option)
Expand Down Expand Up @@ -120,9 +132,9 @@ Added in v1.0.0
- [TaggedClass](#taggedclass)
- [TaggedError](#taggederror)
- [TaggedRequest](#taggedrequest)
- [TaggedRequest (interface)](#taggedrequest-interface)
- [TaggedRequest (namespace)](#taggedrequest-namespace)
- [Base (interface)](#base-interface)
- [ResultSchemas (interface)](#resultschemas-interface)
- [Any (type alias)](#any-type-alias)
- [combinators](#combinators)
- [array](#array)
- [attachPropertySignature](#attachpropertysignature)
Expand Down Expand Up @@ -562,6 +574,63 @@ export declare const negateBigDecimal: <I, A extends BigDecimal.BigDecimal>(self

Added in v1.0.0

# Cause

## CauseFrom (type alias)

**Signature**

```ts
export type CauseFrom<E> =
| {
readonly _tag: "Die"
readonly defect: unknown
}
| {
readonly _tag: "Empty"
}
| {
readonly _tag: "Fail"
readonly error: E
}
| {
readonly _tag: "Interrupt"
readonly fiberId: FiberIdFrom
}
| {
readonly _tag: "Parallel"
readonly left: CauseFrom<E>
readonly right: CauseFrom<E>
}
| {
readonly _tag: "Sequential"
readonly left: CauseFrom<E>
readonly right: CauseFrom<E>
}
```

Added in v1.0.0

## cause

**Signature**

```ts
export declare const cause: <EI, E>(error: Schema<EI, E>) => Schema<CauseFrom<EI>, Cause.Cause<E>>
```

Added in v1.0.0

## causeFromSelf

**Signature**

```ts
export declare const causeFromSelf: <IE, E>(error: Schema<IE, E>) => Schema<Cause.Cause<IE>, Cause.Cause<E>>
```

Added in v1.0.0

# Chunk transformations

## chunk
Expand Down Expand Up @@ -780,6 +849,97 @@ export declare const eitherFromSelf: <IE, E, IA, A>(

Added in v1.0.0

# Exit

## ExitFrom (type alias)

**Signature**

```ts
export type ExitFrom<E, A> =
| {
readonly _tag: "Failure"
readonly cause: CauseFrom<E>
}
| {
readonly _tag: "Success"
readonly value: A
}
```

Added in v1.0.0

## exit

**Signature**

```ts
export declare const exit: <IE, E, IA, A>(
error: Schema<IE, E>,
value: Schema<IA, A>
) => Schema<ExitFrom<IE, IA>, Exit.Exit<E, A>>
```

Added in v1.0.0

## exitFromSelf

**Signature**

```ts
export declare const exitFromSelf: <IE, E, IA, A>(
error: Schema<IE, E>,
value: Schema<IA, A>
) => Schema<Exit.Exit<IE, IA>, Exit.Exit<E, A>>
```

Added in v1.0.0

# FiberId

## FiberId

**Signature**

```ts
export declare const FiberId: Schema<FiberIdFrom, FiberId.FiberId>
```

Added in v1.0.0

## FiberIdFrom (type alias)

**Signature**

```ts
export type FiberIdFrom =
| {
readonly _tag: "Composite"
readonly left: FiberIdFrom
readonly right: FiberIdFrom
}
| {
readonly _tag: "None"
}
| {
readonly _tag: "Runtime"
readonly id: number
readonly startTimeMillis: number
}
```

Added in v1.0.0

## FiberIdFromSelf

**Signature**

```ts
export declare const FiberIdFromSelf: Schema<FiberId.FiberId, FiberId.FiberId>
```

Added in v1.0.0

# Option transformations

## OptionFrom (type alias)
Expand Down Expand Up @@ -1487,8 +1647,8 @@ Added in v1.0.0
```ts
export declare const TaggedRequest: <Self>() => <Tag extends string, Fields extends StructFields, EI, EA, AI, AA>(
tag: Tag,
failure: Schema<EI, EA>,
success: Schema<AI, AA>,
Failure: Schema<EI, EA>,
Success: Schema<AI, AA>,
fields: Fields
) => [unknown] extends [Self]
? 'Missing `Self` generic - use `class Self extends TaggedRequest<Self>()("Tag", SuccessSchema, FailureSchema, { ... })`'
Expand All @@ -1505,38 +1665,48 @@ export declare const TaggedRequest: <Self>() => <Tag extends string, Fields exte
>,
Simplify<ToStruct<Fields>>,
Self,
Request.Request<EA, AA>
> &
TaggedRequest.ResultSchemas<EI, EA, AI, AA>
TaggedRequest<
Tag,
Simplify<
{ readonly _tag: Tag } & {
readonly [K in Exclude<keyof Fields, FromOptionalKeys<Fields>>]: Schema.From<Fields[K]>
} & { readonly [K in FromOptionalKeys<Fields>]?: Schema.From<Fields[K]> | undefined }
>,
Self,
EI,
EA,
AI,
AA
>
>
```

Added in v1.0.0

## TaggedRequest (namespace)

Added in v1.0.0

### Base (interface)
## TaggedRequest (interface)

**Signature**

```ts
export interface Base<EI, EA, AI, AA, I, Req extends Request.Request<EA, AA> & { readonly _tag: string }>
extends Schema<I, Req>,
TaggedRequest.ResultSchemas<EI, EA, AI, AA> {}
export interface TaggedRequest<Tag extends string, IS, S, IE, E, IA, A>
extends Request.Request<E, A>,
Serializable.SerializableWithResult<IS, S, IE, E, IA, A> {
readonly _tag: Tag
}
```

Added in v1.0.0

### ResultSchemas (interface)
## TaggedRequest (namespace)

Added in v1.0.0

### Any (type alias)

**Signature**

```ts
export interface ResultSchemas<EI, EA, AI, AA> {
readonly Failure: Schema<EI, EA>
readonly Success: Schema<AI, AA>
}
export type Any = TaggedRequest<string, any, any, any, any, any, any>
```

Added in v1.0.0
Expand Down
Loading
Loading