第一次尝试变压器(某种),我正在尝试使用以下功能:
getEnvList :: Text -> IO (Either String [Text])
在做的块
type EitherIO a = ExceptT String IO a
script :: EitherIO ()
我认为我应该能够做到这一点:
entryKeys :: [Text] <- pure $ getEnvList active_cac_entries
但是,我收到此错误:
• Couldn't match expected type ‘IO (Either String [Text])’
with actual type ‘[Text]’
• When checking that the pattern signature: [Text]
fits the type of its context: IO (Either String [Text])
In the pattern: entryKeys :: [Text]
In a stmt of a 'do' block:
entryKeys :: [Text] <- pure $ getEnvList active_cac_entries
|
93 | entryKeys :: [Text] <- pure $ getEnvList active_cac_entries
| ^^^^^^^^^^^^^^^^^^^
在这种情况下,正确的函数是ExceptT
构造函数:
ExceptT :: m (Either e a) -> ExceptT e m a
-- do ...
-- entry <- ExceptT $ getEnvList active_cac_entries
-- ...
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句