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)’
答案 0 :(得分:2)
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
种类。检查你的进口。
答案 1 :(得分:0)
编辑:我误读了原来的问题
您是否尝试过使用fromString
课程中的IsString
? Data.Text.Internal.Lazy.Text
应该是IsString
老(没用)回答:
使用pack
中的Data.Text.Lazy
功能将String
转换为Text
https://hackage.haskell.org/package/text-1.2.3.0/docs/Data-Text-Lazy.html