[Haskell-beginners] Compiler can't deduce Bool as instance of ToField

Bryan Vicknair bryanvick at gmail.com
Wed Aug 14 11:25:02 CEST 2013


postgresql-simple declares Bool as an instance of the ToField class.  The
compiler can't deduce that given this simple code however:

  import Database.PostgreSQL.Simple.ToField (ToField(..))
  
  foo :: (ToField a) => a
  foo = True
  
  
It fails with this error:

  Db.hs:64:7:
      Could not deduce (a ~ Bool)
      from the context (ToField a)
        bound by the type signature for foo :: ToField a => a
        at Db.hs:63:8-23
        `a' is a rigid type variable bound by
            the type signature for foo :: ToField a => a at Db.hs:63:8
      In the expression: True
      In an equation for `foo': foo = True
  Failed, modules loaded: none.

What am I missing?




More information about the Beginners mailing list