我是haskell的新手,我正在创建一个我所关注的所有博客/网站的RSS源,就像新闻源一样,但是我遇到了障碍。
rssFeed :: Snap ()
rssFeed =
feed <- parseFeedString "https://news.ycombinator.com/rss"
putStrLn (ppTopElement $ xmlFeed feed)
这是创建Feed的主要功能,但在编译时我会收到此错误
Resolving dependencies...
Configuring feedre-0.1...
Building feedre-0.1...
Preprocessing executable 'feedre' for feedre-0.1...
[1 of 1] Compiling Main ( src/Main.hs, dist/build/feedre/feedre-tmp/Main.o )
src/Main.hs:26:14: parse error on input `<-'
Failed to install feedre-0.1
cabal: Error: some packages failed to install:
feedre-0.1 failed during the building phase. The exception was:
ExitFailure 1
答案 0 :(得分:1)
我认为你只错过do
:
rssFeed :: Snap ()
rssFeed = do
feed <- parseFeedString "https://news.ycombinator.com/rss"
putStrLn (ppTopElement $ xmlFeed feed)
因为<-
来自do-notation
。
我不知道Snap
monad的外观如何,但我猜您liftIO
可能需要putStrLn
:
liftIO $ putStrLn (ppTopElement $ xmlFeed feed)