Folktale should support converting from Promises to a more usable type. Because Promises are already eventual values, it makes sense to convert the functions that create them to functions creating Tasks instead of converting actual Promises to Tasks.
In essence, a function yielding a Promise, like:
f :: (Any...) => Promise Error Any
Would become a function yielding a Task, like:
promiseFunctionToTask(f) :: (Any...) => Task Error Any
promiseFunctionToTask is a really long name, though, so if you have better naming suggestions feel free to discuss them here :)
Where this goes?
In the data/conversions module, as promiseFunctionToTask.
In the data/task module, as fromPromiseFunction.
Refer to existing data/conversions modules, and the from* functions in data/maybe and data/either to see more or less how this is done.
Folktale should support converting from Promises to a more usable type. Because Promises are already eventual values, it makes sense to convert the functions that create them to functions creating Tasks instead of converting actual Promises to Tasks.
In essence, a function yielding a Promise, like:
Would become a function yielding a Task, like:
promiseFunctionToTask
is a really long name, though, so if you have better naming suggestions feel free to discuss them here :)Where this goes?
In the
data/conversions
module, aspromiseFunctionToTask
. In thedata/task
module, asfromPromiseFunction
.Refer to existing
data/conversions
modules, and thefrom*
functions indata/maybe
anddata/either
to see more or less how this is done.