haskell-hvr / cassava

A CSV parsing and encoding library optimized for ease of use and high performance
http://hackage.haskell.org/package/cassava
BSD 3-Clause "New" or "Revised" License
222 stars 105 forks source link

Error: ‘toNamedRecord’ is not a (visible) method of class ‘ToNamedRecord’ #173

Closed alexander-myltsev closed 11 months ago

alexander-myltsev commented 5 years ago

I'm using GHCi, version 8.6.5. The example

data Person = Person { name :: !Text, age :: !Int }

instance ToNamedRecord Person where
    toNamedRecord (Person name age) = namedRecord [
        "name" .= name, "age" .= age]

Fails with the error ‘toNamedRecord’ is not a (visible) method of class ‘ToNamedRecord’. Is that the bug? How to define it properly?

billksun commented 11 months ago

Just hit this error myself. @alexander-myltsev did you ever find a solution for this?

Edit: Looks like I just forgot (..) in the import statement:

import Data.Csv (... ToNamedRecord (..) ...)
andreasabel commented 11 months ago

Then I take this as the answer!