Eff
我有以下用s 和s编写的程序Aff
。按预期运行。那就是它打印出给定的Int
并进行异步计算。
type JsonResponse = AffjaxResponse Json
access :: forall e m. Aff (ajax :: AJAX | e) (Either Error JsonResponse)
access = attempt $ get "http://localhost:8080/livesys/Robert"
staging :: forall e. Int -> Eff (console :: CONSOLE | e) Int
staging i = do
liftEff $ log $ ">>" ++ show i
return i
main :: forall a. Int -> Aff (ajax :: AJAX, console :: CONSOLE| a) Int
main state = do
s <- liftEff $ staging state
a <- liftAff access
return s
但是,如果我更改其中的调用顺序,main
则会发生一些神秘的事情:
main :: forall a. Int -> Aff (ajax :: AJAX, console :: CONSOLE| a) Int
main state = do
a <- liftAff access
s <- liftEff $ staging state
return s
该函数staging
现在被调用了两次!呜?
有人可以解释一下吗?
谢谢你的帮助