Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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/afraid-phones-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/workflow": patch
---

Add Workflow type utils
5 changes: 5 additions & 0 deletions .changeset/gold-doors-wish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

Add `Chunk.getSomes`
7 changes: 7 additions & 0 deletions packages/effect/src/Chunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1493,3 +1493,10 @@ export const difference: {
2,
<A>(self: Chunk<A>, that: Chunk<A>): Chunk<A> => unsafeFromArray(RA.difference(that, self))
)

/**
* @category filtering
* @since 3.19.0
*/
export const getSomes: <A>(self: Chunk<Option<A>>) => Chunk<A> = (self) =>
unsafeFromArray(RA.getSomes(toReadonlyArray(self)))
5 changes: 5 additions & 0 deletions packages/effect/test/Chunk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -887,4 +887,9 @@ describe("Chunk", () => {
assertEquals(Chunk.difference(curr, Chunk.empty()), Chunk.empty())
assertEquals(Chunk.difference(curr, curr), Chunk.empty())
})

it("getSomes", () => {
assertEquals(Chunk.getSomes(Chunk.empty()), Chunk.empty())
assertEquals(Chunk.getSomes(Chunk.make(Option.some(1), Option.none())), Chunk.of(1))
})
})
35 changes: 35 additions & 0 deletions packages/workflow/src/Workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,41 @@ import type { WorkflowEngine, WorkflowInstance } from "./WorkflowEngine.js"
*/
export const TypeId: unique symbol = Symbol.for("@effect/workflow/Workflow")

/**
* @since 1.0.0
*/
export declare namespace Workflow {
/**
* Extracts the type of the Payload of a `Workflow`.
*
* @since 1.0.0
* @category Type-level Utils
*/
export type Payload<W extends Workflow<any, any, any, any>> = W extends Workflow<any, infer Payload, any, any>
? Payload["Type"]
: never

/**
* Extracts the type of the Success of a `Workflow`.
*
* @since 1.0.0
* @category Type-level Utils
*/
export type Success<W extends Workflow<any, any, any, any>> = W extends Workflow<any, any, infer Success, any>
? Success["Type"]
: never

/**
* Extracts the type of the Error of a `Workflow`.
*
* @since 1.0.0
* @category Type-level Utils
*/
export type Error<W extends Workflow<any, any, any, any>> = W extends Workflow<any, any, any, infer Error>
? Error["Type"]
: never
}

/**
* @since 1.0.0
* @category Symbols
Expand Down