我有得到一個問題,下面來編譯:liftEff影響排式統一
module ContrivedExample where
import Prelude
import Data.Either (Either(..))
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Exception (EXCEPTION, throw)
import Control.Monad.Eff.Console (CONSOLE, log)
import Control.Monad.Eff.Class (liftEff)
import Control.Monad.Aff (launchAff)
import Control.Monad.Aff.Console (log) as A
contrivedExample :: forall e. Either String String -> Eff (exception :: EXCEPTION, console :: CONSOLE | e) Unit
contrivedExample a = do
_ <- launchAff do
_ <- A.log "yay"
liftEff $ case a of
Left e -> log e
Right a -> throw a
pure unit
我得到這個錯誤:
Could not match type
(console :: CONSOLE
| e3
)
with type
(exception :: EXCEPTION
, console :: CONSOLE
| t2
)
如果我從影響行刪除異常,我得到在Either
的另一端出現錯誤。有沒有更好的選擇liftEff或某種方式我可以統一類型?