【问题标题】:readCol = map fromSql non type-variable argumentreadCol = map fromSql 非类型变量参数
【发布时间】:2022-01-26 03:31:56
【问题描述】:
:i fromSql 
fromSql ::
  convertible-1.1.1.0:Data.Convertible.Base.Convertible SqlValue a =>
  SqlValue -> a
        -- Defined in ‘Database.HDBC.SqlValue’

如果我运行例如 map fromSql (EXAMPLESQL) 它输出正常。但如果我将其重新定义为 readCol = map fromSql 我会收到错误消息:

readCol = map fromSql

<interactive>:23:1: error:
    • Non type-variable argument
        in the constraint: convertible-1.1.1.0:Data.Convertible.Base.Convertible
                             SqlValue b
      (Use FlexibleContexts to permit this)
    • When checking the inferred type
        readCol :: forall b.
                   convertible-1.1.1.0:Data.Convertible.Base.Convertible SqlValue b =>
                   [SqlValue] -> [b]

如何解决?

【问题讨论】:

  • 按照建议,启用 FlexibleContexts。它是非常可靠和值得信赖的扩展。我认为它肯定会被整合到即将发布的 haskell 报告中。
  • 谢谢。我已经相应地设置了解决方案。解决方案在这里stackoverflow.com/questions/21375556/…

标签: database sqlite haskell


【解决方案1】:

我使用了this的解决方案:

在 ghci 中,您可以像这样设置 FlexibleContexts:

:set -XFlexibleContexts

在源文件的开头,你应该使用:

{-# LANGUAGE FlexibleContexts #-}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多