haskell - No instance for Database.SQLite.Simple.FromField.FromField Char -
this code gives me error:
67: isfileinstalled f = 68: dbcon <- open "/var/lib/beaver/pkgs.db" 69: res <- querynamed dbcon "select * files path = :path" [":path" := ("/usr/bin/getpkg" :: string)] 70: mapm_ putstrln res 71: -- when (null res) (return ()) 72: -- putstrln ("file " ++ res ++ " installed , comes " ++ res ++ ".") -- first res `owner` , second `path` 73: close dbcon 74: exit
i error:
no instance (database.sqlite.simple.fromfield.fromfield char) arising use of `querynamed' in stmt of 'do' block: res <- querynamed dbcon "select * files path = :path" [":path" := ("/usr/bin/getpkg" :: string)] in expression: { dbcon <- open "/var/lib/beaver/pkgs.db"; res <- querynamed dbcon "select * files path = :path" [":path" := ("/usr/bin/getpkg" :: string)]; mapm_ putstrln res; close dbcon; .... } in equation `isfileinstalled': isfileinstalled f = { dbcon <- open "/var/lib/beaver/pkgs.db"; res <- querynamed dbcon "select * files path = :path" [":path" := ("/usr/bin/getpkg" :: string)]; mapm_ putstrln res;
i didn't find in google. if it's important, overloadedstrings enabled. there workaround (or way fix it)?
you using res
[string]
:
mapm_ putstrln res
it equivalent [[char]]
. querynamed
returns list of rows, each row has type [char]
. there instance fromfield => fromrow [a]
, there no instance fromfield char
. error messages says.
i never used sqlite-simple
, clear each row contains number of fields, trying fetch row contains number of fields of type char
. makes no sense. depending on actual database scheme, each row should e.g. number of text field, res
can have type [[string]]
. in case should use next:
mapm_ (mapm_ putstrln) (res :: [[string]])
Comments
Post a Comment