Here's a snippet of a Haskell program I'm trying to understand:
englishToFrench = [("the", "le"),("savage", "violent"),("work", "travail"),
("wild", "sauvage"),("chance", "occasion"),]
data Entry = Entry {word :: String,
definition :: String,
length' :: Int}
deriving Show
listOfEntries = map (\(x, y) -> Entry x y (length x)) englishToFrench
Briefly, the program takes a list of String tuples and turns out a list of Entry objects.
However, I don't like the lambda functions in the map and I'd like to create a regular function to replace it.
I attempted this but it is giving me an error that x and y are not in the scope:
entryBuilder x y = Entry x y (length x)
entries = map (entryBuilder x y) englishToFrench
Can anyone tell me how to convert the lambda function and what the general method is?