正如标题所说,我正在尝试在我的 handleAction 函数中使用 logShow。我导入Effect.Console (logShow)
并尝试像这样使用它,每次单击按钮时:
handleAction ∷ forall o m. Action → H.HalogenM State Action () o m Unit
handleAction = case _ of
Update -> do
logShow "Hello"
H.modify_ \st -> st { field3 = st.field3 + 1 }
但是我只收到以下错误,而且我不太了解,因为我对纯脚本和函数式编程完全陌生。
Could not match type
Effect
with type
HalogenM
{ field1 :: Int
, field2 :: Int
, field3 :: Int
}
Action
()
o0
m1
while trying to match type Effect t2
with type HalogenM
{ field1 :: Int
, field2 :: Int
, field3 :: Int
}
Action
()
o0
m1
Unit
while checking that expression (discard (logShow "Hello")) (\$__unused -> modify_ (\st -> ... ))
has type HalogenM
{ field1 :: Int
, field2 :: Int
, field3 :: Int
}
Action
()
o0
m1
Unit
in value declaration handleAction
where m1 is a rigid type variable
bound at (line 77, column 16 - line 80, column 51)
o0 is a rigid type variable
bound at (line 77, column 16 - line 80, column 51)
t2 is an unknown type
PureScript(TypesDoNotUnify)
我很高兴有任何线索。