This executes:
main = do
ctx <- getCanvasElementById "stage" >>= getContext2D
bs <- initBranches
tick 0 ctx bs
but this does not:
main = tick 0 <$> (getCanvasElementById "stage" >>= getContext2D)
<*> initBranches
however both compile, and to my understanding both mean the same basic thing. Why is this the case? Can I use the applicative syntax here (its much more understandable imho)
this also works
main = do
a <- (tick 0) <$> (getCanvasElementById "stage" >>= getContext2D) <*> initBranches
b <- a
fprint b
main = join $ tick 0 <$> (getCanvasElementById "stage" >>= getContext2D)
<*> initBranches
the applicative creates a nested Eff, join resolves this easily
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.