Short-and-sweet, I have a text file that looks like this:
ID1|ID2|DATE|SUM
0|0|20/03/2014|100.00
0|1|20/04/2014|99.00
I have a custom data type that looks like this:
data DBData = DBData { id1 :: Int
, id2 :: Int
, date :: String
, sum :: Int
} deriving (Eq, Read, Show)
How do I get this into that?
What I have been toying with so far is using something like this:
parseRow :: [String] -> DBData
parseRow = let (id1:id2:date:sum) = (splitWhen (=='|')) s
i = read id1
in DBData {id1 = i}
But I can't seem to get the syntax right ...
related to my other post: https://stackoverflow.com/questions/25477554/using-splitwhen-to-split-string-by-delimiter-and-trying-to-figure-out-how-to-sto