簡體   English   中英

Haskell:Yesod和Esqueleto

[英]Haskell: Yesod and Esqueleto

如何在Yesod 1.2中獲得runDB與Esqueleto一起使用?

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"

這是錯誤輸出:

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)

這是一個依賴問題。 Esqueleto必須使用最新版本的persistent和persistent-sqlite進行編譯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM