Because promises of promises are automatically "flattened", any nesting of promises is likely to lead to runtime errors. Consider:
module Main where
import Prelude
import Effect (Effect)
import Effect.Console (logShow)
import Effect.Promise (Promise)
import Effect.Promise as Promise
import Effect.Promise.Console as Promise.Console
main = Promise.runPromise logShow logShow do
hello <- Promise.resolve (Promise.resolve "hello")
hello' <- hello
Promise.Console.log (hello' <> ", world")
which, when run, outputs this:
TypeError: promise.then is not a function
at Object.exports.thenImpl (/home/harry/code/ps-scratch/output/Effect.Promise/foreign.js:2:18)
at /home/harry/code/ps-scratch/output/Effect.Promise/index.js:55:29
at /home/harry/code/ps-scratch/output/Data.Function/index.js:16:24
at /home/harry/code/ps-scratch/output/Main/index.js:11:70
I'm not sure if this is fixable but it may be worth documenting, at least.
Because promises of promises are automatically "flattened", any nesting of promises is likely to lead to runtime errors. Consider:
which, when run, outputs this:
I'm not sure if this is fixable but it may be worth documenting, at least.