Open aloussase opened 1 month ago
When I want to abstract over the type of Monad (for example when using tagless final) I end up having to write code like this:
export const register = <F extends URIS>(F: UserSymmantics<F> & MonadTask1<F>) => (username: string, password: string) => { const flatMap = <A, B>(f: (a: A) => Kind<F, B>) => (ma: Kind<F, A>): Kind<F, B> => F.chain(ma, f) return pipe( F.fromTask(() => hash(password, 10)), flatMap(hashedPassword => F.createUser(username, hashedPassword)), ) }
Which is not too bad, but I'd prefer not to write the flatMap function. I'm basing this on the fp to the max example from the repository. Isn't there a more ergonomic way of writing code like this?
Thank you very much.
When I want to abstract over the type of Monad (for example when using tagless final) I end up having to write code like this:
Which is not too bad, but I'd prefer not to write the flatMap function. I'm basing this on the fp to the max example from the repository. Isn't there a more ergonomic way of writing code like this?
Thank you very much.