首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Haskell: Yesod和Esqueleto

Haskell: Yesod和Esqueleto
EN

Stack Overflow用户
提问于 2014-03-29 04:50:39
回答 1查看 677关注 0票数 1

如何让Yesod1.2中的runDB与Esqueleto一起工作?

代码语言:javascript
复制
import Database.Esqueleto as E
getMainR :: Handler Html
getMainR = do
        leases <- runDB $ E.select $ 
                          E.from $ \l -> do
                          E.where_ (l E.^. LeaseId E.==. E.val 1)
                          return l

        defaultLayout $ do
          setTitle "Main"

以下是错误输出:

代码语言:javascript
复制
Handler/Main.hs:41:27:
    Couldn't match type `persistent-1.3.0.6:Database.Persist.Sql.Types.SqlPersistT'
                  with `SqlPersistT'
    Expected type: YesodDB App [E.Entity val0]
      Actual type: SqlPersistT (HandlerT App IO) [E.Entity val0]
    In the second argument of `($)', namely
      `select
       $ from
         $ \ l
             -> do { where_ (l ^. LeaseId ==. val 1);
                     return l }'
    In a stmt of a 'do' block:
      leases <- runDB
                $ select
                  $ from
                    $ \ l
                        -> do { where_ (l ^. LeaseId ==. val 1);
                                return l }
    In the expression:
      do { leases <- runDB $ select $ from $ \ l -> do { ... };
           defaultLayout $ do { setTitle "Tenants" } }

Handler/Main.hs:42:41:
    Couldn't match expected type `E.EntityField val0 typ0'
                with actual type `Import.EntityField
                                    Lease
                                    (Import.KeyBackend
                                       persistent-1.3.0.6:Database.Persist.Sql.Types.SqlBackend
                                       Lease)'
    In the second argument of `(^.)', namely `LeaseId'
    In the first argument of `(==.)', namely `l ^. LeaseId'
    In the first argument of `where_', namely
      `(l ^. LeaseId ==. val 1)'

我试图遵循本教程,但似乎他们的runDB设置与Yesod脚手架的设置不同。https://github.com/yesodweb/yesod/wiki/Multi-select-field-populated-from-database-(using-esqueleto)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-29 08:00:28

这是一个依赖问题。Esqueleto必须用最新版本的持久和持久的sqlite来编译。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22727162

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档