1

Combining Ramda and Folktale functors

_fetchLists is a function that performs an async operation, it takes the following arguments:

  1. fetchAlllists: an async function that resolves with Result functor of an array of list objects
  2. listIds: an array of listIds

    it returns a Result functor of an array of list objects

    • Is _fetchLists considered a pure function?
    • fetchAlllists is implemented to return a promise that resolves with a Result, is there a benefit from using Task functor instead of normal promise?
const _fetchLists = R.curry(
  async(fetchAllLists, listIds) => {
    const lists = await fetchAllLists();

    return R.map(
      R.compose(
        R.values,
        R.pick(listIds),
        R.indexBy(R.prop('id'))
      ),
      lists
    );
  }
);
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Nizar
  • 21
  • 1
  • 1
  • 3
  • 2
    A function creating a promise is not pure because it starts the (often impure) work and uses a global scheduler, while a `Task` is purely representing the *capability* to do asynchronous work. – Bergi Jul 10 '18 at 13:32

0 Answers0