[英]How to compare for equality Data.Text.Internal.Lazy.Text and [Char]?
esqueleto返回的previousLogItem
數據類型包含Data.Text.Internal.Lazy.Text
import Data.Text.Lazy (pack)
previousLogItem <- select $ from $ \l -> do
orderBy [desc (l ^. LogItemId)]
limit 1
return (l ^. LogItemTitle)
后來我嘗試使用以下方法將previousLogItem
與exampleCharList
進行比較:
[Value (pack currentWindowTitle)] == previousLogItem
但這不起作用,因為類型仍然不同:
Couldn't match type ‘Data.Text.Internal.Lazy.Text’
with ‘Text’
NB: ‘Text’ is defined in ‘Data.Text.Internal’
‘Data.Text.Internal.Lazy.Text’
is defined in ‘Data.Text.Internal.Lazy’
arising from a functional dependency between:
constraint ‘Database.Esqueleto.Internal.Sql.SqlSelect
(SqlExpr (Value Text)) (Value Data.Text.Internal.Lazy.Text)’
arising from a use of ‘select’
instance ‘Database.Esqueleto.Internal.Sql.SqlSelect
(SqlExpr (Value a)) (Value a)’
Couldn't match type ‘Data.Text.Internal.Lazy.Text’
with ‘Text’
NB: ‘Text’ is defined in ‘Data.Text.Internal’
‘Data.Text.Internal.Lazy.Text’
您使用的是錯誤的Text
。 檢查您的進口。
編輯:我看錯了原始問題
您是否嘗試過使用IsString
類中的fromString
? Data.Text.Internal.Lazy.Text
應該是一個實例IsString
舊的(無用的)答案:
使用Data.Text.Lazy
的pack
函數將String
轉換為Text
https://hackage.haskell.org/package/text-1.2.3.0/docs/Data-Text-Lazy.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.