鉴于websockets example如何在Handler
内部runDB
进行runDB $ selectList ...
相关操作(例如chatStream :: WebSocketsT Handler ()
chatStream = do
users <- liftIO $ runDB $ selectList [] [] :: Handler [Entity User] -- This line is not working
sendTextData ("Welcome to the chat server, please enter your name." :: Text)
-- ....
)
这是我想要做的一个非工作的例子:
Couldn't match type ‘HandlerT App IO [Entity User]’
with ‘ReaderT
websockets-0.9.7.0:Network.WebSockets.Connection.Connection
Handler
t0’
Expected type: ReaderT
websockets-0.9.7.0:Network.WebSockets.Connection.Connection
Handler
t0
Actual type: Handler [Entity User]
In a stmt of a 'do' block:
users <- liftIO $ runDB $ selectList [] [] :: Handler [Entity User]
这是错误:
Error:(27, 13) Failed to resolve: com.google.android.gms:play-services:9.4.0
Install Repository and sync project
Show in File
Show in Project Structure dialog
答案 0 :(得分:1)
答案是使用lift
而非liftIO
users <- lift $ (runDB $ selectList [] [] :: Handler [Entity User])