0

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)’
4

2 回答 2

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. 检查你的进口。

于 2018-04-19T05:14:08.360 回答
0

编辑:我误读了原始问题

您是否尝试过fromStringIsString课堂上使用?Data.Text.Internal.Lazy.Text应该是一个实例IsString

旧(无用)答案:

使用pack函数 fromData.Text.Lazy将 to 转换StringText

https://hackage.haskell.org/package/text-1.2.3.0/docs/Data-Text-Lazy.html

于 2018-04-19T03:44:10.527 回答