Hud
Hud

Reputation: 301

readCol = map fromSql non type-variable argument

:i fromSql 
fromSql ::
  convertible-1.1.1.0:Data.Convertible.Base.Convertible SqlValue a =>
  SqlValue -> a
        -- Defined in ‘Database.HDBC.SqlValue’

If I run e.g map fromSql (EXAMPLESQL) it outputs ok. But if I redefine it as readCol = map fromSql I get the error:

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]

How to solve this?

Upvotes: 0

Views: 31

Answers (1)

Hud
Hud

Reputation: 301

I used the solution from this:

In ghci you can set FlexibleContexts like this:

:set -XFlexibleContexts

In the source file, at the beginning, you should use:

{-# LANGUAGE FlexibleContexts #-}

Upvotes: 1

Related Questions