Giter Site home page Giter Site logo

Why no ApplicativeSeq for Task? about fun HOT 3 CLOSED

baetheus avatar baetheus commented on August 23, 2024
Why no ApplicativeSeq for Task?

from fun.

Comments (3)

baetheus avatar baetheus commented on August 23, 2024

There is a Sequential Apply for Task here. The only difference between apply and applicative is the of constructor. I can see how you'd need the Applicative module for traverse and should be able to implement it this weekend. I'd also welcome a PR if you're up to it. Unfortunately, Deno 1.10 generates better coverage reports (that show functional missing some branches in testing) so I was hoping to fix that first. Anyway, thanks for the find!

from fun.

cryptogohan avatar cryptogohan commented on August 23, 2024

I quickly whippped up:

import { ApplySeq } from "https://deno.land/x/[email protected]/task.ts";
import type * as TC from "https://deno.land/x/[email protected]/type_classes.ts";

const URI = "Task";
type URI = typeof URI;
const Functor: TC.Functor<URI> = {
  map: (fab) => (ta) => () => ta().then(fab),
};
export const ApplicativeSeq: TC.Applicative<URI> = {
  of: (a) => () => Promise.resolve(a),
  ap: ApplySeq.ap,
  map: Functor.map,
};

But then didn't end up testing or actually even using it haha 😅 .

I'm a bit tight on time right now. Next time I need it, if it isn't there, I'm happy to take a shot.

Perhaps this already helps someone else.

from fun.

baetheus avatar baetheus commented on August 23, 2024

Yeah, I'd do basically the same thing:

import type * as TC from "https://deno.land/x/[email protected]/type_classes.ts";
import * as T from "https://deno.land/x/[email protected]/task.ts";

const ApplicativeSeq: TC.Applicative<T.URI> = {
  of: T.of,
  ap: ApplySeq.ap,
  map: T.map,
}

from fun.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.