我刚刚开始使用netwire,我遇到了很多基础问题.
以下代码对我来说很好:
main :: IO () main = testWire clockSession_ (for 3 . yeah) yeah :: Monad m => Wire s () m a String yeah = pure "yes"
但这不是:
main :: IO () main = testWire clockSession_ forYeah forYeah :: (Show b, Show e) => Wire s e Identity a b forYeah = for 3 . yeah
失败并出错:
Could not deduce (b ~ [Char]) from the context (Show b, Show e) bound by the type signature for forYeah :: (Show b, Show e) => Wire s e Identity a b at /home/fiendfan1/workspace/Haskell/Haskell-OpenGL/src/Main.hs:12:12-54 `b' is a rigid type variable bound by the type signature for forYeah :: (Show b, Show e) => Wire s e Identity a b at /home/fiendfan1/workspace/Haskell/Haskell-OpenGL/src/Main.hs:12:12 Expected type: Wire s e Identity a b Actual type: Wire s () Identity a String In the second argument of `(.)', namely `yeah' In the expression: for 3 . yeah In an equation for `forYeah': forYeah = for 3 . yeah
所以我改成了:
forYeah :: Show e => Wire s e Identity a String
这给了我错误:
Could not deduce (e ~ ()) from the context (Show e) bound by the type signature for forYeah :: Show e => Wire s e Identity a String at /home/fiendfan1/workspace/Haskell/Haskell-OpenGL/src/Main.hs:12:12-49 `e' is a rigid type variable bound by the type signature for forYeah :: Show e => Wire s e Identity a String at /home/fiendfan1/workspace/Haskell/Haskell-OpenGL/src/Main.hs:12:12 Expected type: Wire s e Identity a String Actual type: Wire s () Identity a String In the second argument of `(.)', namely `yeah' In the expression: for 3 . yeah In an equation for `forYeah': forYeah = for 3 . yeah
将其更改为:
forYeah :: Wire s () Identity a String
给出以下错误:
No instance for (HasTime Integer s) arising from a use of `for' Possible fix: add an instance declaration for (HasTime Integer s) In the first argument of `(.)', namely `for 3' In the expression: for 3 . yeah In an equation for `forYeah': forYeah = for 3 . yeah
有人可以解释为什么会发生这种情况以及如何修复我的第二个代码示例?