Thanks to this excellent tutorial, I know how to read a string (in this case read from a file at people.txt
directly into a type synonym:
type Person = [Int]
like this:
people_text <- readFile "people.txt"
let people :: [Person]
people = read people_text
What I want to do is use a datatype (instead of a type synonym).
Any pointers on what I am missing here? I thought I would be able to read string-data directly into a Person
- defined like this (credit to learnyouahaskell.com)
data Person = Person String String Int Float String String deriving (Show)
When I try the obvious
txt <- readFile "t.txt" (this works OK)
with t.txt
containing
"Buddy" "Finklestein" 43 184.2 "526-2928" "Chocolate"
I get this error:
No instance for
(Read Person)