Replies: 4 comments 2 replies
-
I've been thinking about adding a somewhat generic Error type to fun, it's primary use is to wrap code from outside of fun that might throw in or out of a promise. Currently, tryCatch in Option, Either, and TaskEither are very useful for wrapping these types. However, I find myself often doing the following for each function brought in from an external library: import * as TE from "./task_either.ts";
export type FetchError = {
tag: "FetchError",
args: Parameters<typeof Fetch>,
error: unknown,
};
export const fetchError = (error: unknown, args: Parameters<typeof Fetch>): FetchError => ({
tag: "FetchError",
args,
error,
});
export const safeFetch = TE.tryCatch(fetch, fetchError); One or two of these isn't a big issue for me, but as I use more external code it starts to feel very boilerplatey. This morning I was mucking around with rss parsing (because I will probably land an rss aggregator/reader at some point) and tried out this TaggedError pattern. It's inspired a bit by the anyhow crate that is popular in rust. This simple implementation adds a type level string for tag and an arguments context (a little more specific than an anyhow context). If made into an ADT we could wrap it in Free to add more options for context. |
Beta Was this translation helpful? Give feedback.
-
@baetheus I'm planning to pick up work the coming weeks for RE/RTE, have you touched Either/Reader yet for 2.0? |
Beta Was this translation helpful? Give feedback.
-
Instead of implementing our own observable I'm going to make a compatibility layer over mostjs core via esm.sh. It'll live in contrib/stream.ts and create standard exports over https://esm.sh/@most/[email protected] and https://esm.sh/@most/[email protected]. This is probably a small project, perhaps a day at most. |
Beta Was this translation helpful? Give feedback.
-
Also, I've been working on a prototype http router lib called pick and have been poking at an ADT that is a bit like a mashup of State, Async, and Reader, but not in the standard ReaderStateAsync format, more like Unfortunately, the limitations of the higher kinded type implementation in typescript make it impossible to use the existing type class definitions for indexed monads. This means extra definitions for IxFlatmappable, IxMappable, etc etc etc. It also adds to the complexity of the pick library, which should certainly be kept as simple as possible. |
Beta Was this translation helpful? Give feedback.
-
I'd like to start thinking about useful ADTs and utils to land in fun after the 2.0 release stuff is done. Following is an initial list of the ones I know I'd like to have:
Beta Was this translation helpful? Give feedback.
All reactions