Comments (5)
import { Effect, Option } from "effect"
const filtered = Effect.filter(
[0, 1, 2, "ok", "maybe"],
(v) => v === "nooo" ? Effect.fail(new Error(v)) : Effect.sync(() => typeof v === "number")
)
const filterMapped = Effect.filterMap(
[Effect.succeed(0), Effect.succeed(1), Effect.succeed(2)],
(v) => v > 3 ? Option.none() : Option.some(v + 1)
)
as much as we'd love for the docs to be more complete you won't be able to find examples for every single function in there
from effect.
Messed around a little in REPL and I think I'm understanding how these operators work. The way I think about it is:
// if your filter is simple
array.filter(() => boolean)
// if your filter is complicated or async
Effect.filter(array, (v) => Effect<boolean>)
// if you need to filter and simple map
array.map((v) => NonNullable<any> | null).filter(element => element !== null)
// if you want to filterMap items that are effects
Effect.filterMap(arrayOfEffects, (v) => Option)
Are there plans to add operators such as these? I feel like they could add some flexibility to filtering iterable effects.
Effect.filterEffects(Effect[], () => boolean)
Effect.filterMap(Iterable<A>, () => Effect<Option>)
Effect.fiterMapEffect(Effect[], () => Effect<Option>)
from effect.
Open for discussion what set of filtering functions would be best
from effect.
Cool, will follow that issue. Are y'all open to docs contributions from the community? Can write a couple things as I find them and learn how they work to make it easier for the next person :) I have a feeling this package is gonna be big one day 🚀
from effect.
Cool, will follow that issue. Are y'all open to docs contributions from the community? Can write a couple things as I find them and learn how they work to make it easier for the next person :) I have a feeling this package is gonna be big one day 🚀
of course! contributions are welcome
from effect.
Related Issues (20)
- Effect.Tag with non Effect-returning functions
- From Discord: TypeScript Type Incompatibility Issue with Generic Schema and Optional Values
- Move type helpers from nested namespace to the top-level namespace HOT 4
- From Discord: decode error which should be caught at compile time
- From Discord: Resolving Kysely Integration Issues in Effect with SqlResolver HOT 1
- Generate Mermaid class diagram (or expose DAG) from schema HOT 7
- From Discord: Limitations of `S.TemplateLiteral` Schema Support and the Case for Broader Transform Compatibility
- RuntimeException: Cannot execute an Effect versioned 3.5.6 with a Runtime of version 3.4.7 HOT 4
- Re-evaluate filtering functions HOT 4
- Make HttpClient compatible with Browser HOT 2
- From Discord: Confusion with Prompt.all: Handling Record/Struct Arguments in TypeScript
- From Discord: Lurking in TaggedRequest of `@effect/schema`
- From Discord: OptionFromNonEmptyTrimmedString
- Schema.Trim result in a Parsing Error when using Schema.Class and Schema.TaggedClass with "new" and "make" constructors HOT 1
- `Prompt.text()` fails to receive text pasted from clipboard HOT 1
- From Discord: Making Readonly Array Mutable for schemaSearchParams in HttpServerRequest
- Default Random service not uniquely seeded
- From Discord: Retrieving Annotations from TypeScript Classes
- From Discord: Understanding the Absence of `Context` in `TypeLiteral` Components
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from effect.