切换到Netwire

时间:2015-10-24 04:25:44

标签: haskell frp netwire

我一直在寻找一段时间,我认为我误解了有关转换的一些基本信息。请考虑以下代码

1>assimp.lib(FBXParser.obj) : error LNK2001: unresolved external symbol _inflate
1>assimp.lib(BlenderLoader.obj) : error LNK2019: unresolved external symbol _inflate referenced in function "protected: virtual void __thiscall Assimp::BlenderImporter::InternReadFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct aiScene *,class Assimp::IOSystem *)" (?InternReadFile@BlenderImporter@Assimp@@MAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAUaiScene@@PAVIOSystem@2@@Z)
1>assimp.lib(XGLLoader.obj) : error LNK2001: unresolved external symbol _inflate
1>assimp.lib(XFileParser.obj) : error LNK2001: unresolved external symbol _inflate
1>assimp.lib(unzip.obj) : error LNK2001: unresolved external symbol _inflate
1>assimp.lib(FBXParser.obj) : error LNK2001: unresolved external symbol _inflateEnd
1>assimp.lib(BlenderLoader.obj) : error LNK2019: unresolved external symbol _inflateEnd referenced in function "protected: virtual void __thiscall Assimp::BlenderImporter::InternReadFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct aiScene *,class Assimp::IOSystem *)" (?InternReadFile@BlenderImporter@Assimp@@MAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAUaiScene@@PAVIOSystem@2@@Z)
1>assimp.lib(XGLLoader.obj) : error LNK2001: unresolved external symbol _inflateEnd
1>assimp.lib(XFileParser.obj) : error LNK2001: unresolved external symbol _inflateEnd
1>assimp.lib(unzip.obj) : error LNK2001: unresolved external symbol _inflateEnd
1>assimp.lib(BlenderLoader.obj) : error LNK2019: unresolved external symbol _inflateInit2_ referenced in function "protected: virtual void __thiscall Assimp::BlenderImporter::InternReadFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct aiScene *,class Assimp::IOSystem *)" (?InternReadFile@BlenderImporter@Assimp@@MAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAUaiScene@@PAVIOSystem@2@@Z)
1>assimp.lib(XGLLoader.obj) : error LNK2001: unresolved external symbol _inflateInit2_
1>assimp.lib(XFileParser.obj) : error LNK2001: unresolved external symbol _inflateInit2_
1>assimp.lib(unzip.obj) : error LNK2001: unresolved external symbol _inflateInit2_
1>assimp.lib(AssbinLoader.obj) : error LNK2019: unresolved external symbol _uncompress referenced in function "public: virtual void __thiscall Assimp::AssbinImporter::InternReadFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct aiScene *,class Assimp::IOSystem *)" (?InternReadFile@AssbinImporter@Assimp@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAUaiScene@@PAVIOSystem@2@@Z)
1>assimp.lib(XFileParser.obj) : error LNK2019: unresolved external symbol _inflateSetDictionary referenced in function "public: __thiscall Assimp::XFileParser::XFileParser(class std::vector<char,class std::allocator<char> > const &)" (??0XFileParser@Assimp@@QAE@ABV?$vector@DV?$allocator@D@std@@@std@@@Z)
1>assimp.lib(XFileParser.obj) : error LNK2019: unresolved external symbol _inflateReset referenced in function "public: __thiscall Assimp::XFileParser::XFileParser(class std::vector<char,class std::allocator<char> > const &)" (??0XFileParser@Assimp@@QAE@ABV?$vector@DV?$allocator@D@std@@@std@@@Z)
1>assimp.lib(unzip.obj) : error LNK2019: unresolved external symbol _crc32 referenced in function _unzReadCurrentFile
1>assimp.lib(unzip.obj) : error LNK2019: unresolved external symbol _get_crc_table referenced in function _unzOpenCurrentFile3
1>assimp.lib(FBXParser.obj) : error LNK2019: unresolved external symbol _inflateInit_ referenced in function "void __cdecl Assimp::FBX::`anonymous namespace'::ReadBinaryDataArray(char,unsigned int,char const * &,char const *,class std::vector<char,class std::allocator<char> > &,class Assimp::FBX::Element const &)" (?ReadBinaryDataArray@?A0x110075d1@FBX@Assimp@@YAXDIAAPBDPBDAAV?$vector@DV?$allocator@D@std@@@std@@ABVElement@23@@Z)

注意我在这里只是为了获得所涉及的某些类型的感觉而非常冗长。我期望输出的是10次重复10次,然后我希望mywire :: HasTime t s => Wire s () IO a Int mywire = pure 10 mycont :: HasTime t s => Wire s () IO a (Wire s () IO a Int) mycont = after 10 . pure (pure 20) mycont' :: HasTime t s => Wire s () IO a (Event (Wire s () IO a Int)) mycont' = now . mycont mything :: HasTime t s => Wire s () IO a (Int, Event (Wire s () IO a Int)) mything = (,) <$> mywire <*> mycont' mainwire :: (Monad m, HasTime t s) => Wire s () m a Int mainwire = switch mything main :: IO () main = testWire clockSession_ mainwire 切换到mainwire返回的事件(因为来自mything的事件被延迟10秒钟。)我所看到的是主线禁止10秒,然后是20.为什么我没有看到10开关之前输出的?我认为我误解了切换应该如何工作,任何澄清都会受到赞赏。谢谢。

1 个答案:

答案 0 :(得分:3)

问题出在now . mycont之内。 now会将a直接转换为Event a,因此switch会直接切换到mycont电汇。该导线抑制10秒后输出20。 为了达到您想要的效果,您可以使用at函数:

import Prelude hiding ((.))
import Control.Wire

mywire :: (Monad m, HasTime t s) => Wire s () m a Int
mywire = pure 10

mycont :: (Monad m, HasTime t s) => Wire s () m a (Event (Wire s () m a Int))
mycont = at 10 . pure (pure 20)

mything :: (Monad m, HasTime t s) => Wire s () m a (Int, Event (Wire s () m a Int))
mything = (,) <$> mywire <*> mycont

mainwire :: (Monad m, HasTime t s) => Wire s () m a Int
mainwire = switch mything

main :: IO ()
main = testWire clockSession_ mainwire