I am new to Haskell, and I want to make a program with lists. I want to read from keyboard next element, and append everything to my existing list. Because I used data types, I don't know how to add a new car with all those details, in my list named cars
. I know that sequence let ls = name:model:color:year:price:coin:[cars]
is wrong and I have no ideea how to make it work. Can anyone give me an ideea about what can I do here please?
type Name = Stringtype Model = Stringtype Color= Stringtype Year = Stringtype Price = Stringtype Coin = Stringdata Car = Car String String String String String String deriving (Show)cars :: [Car]cars = [Car "Range Rover""Sport Supercharged""Blue""2015""85790""$" , Car "BMW""4-Series""Black""2014""65489""$"]main = do putStrLn "Car details " putStr "Name: " name <- getLine putStr "Model: " model <- getLine putStr "Color: " color <- getLine putStr "Year: " year <- getLine putStr "Price: " price <- getLine putStr "Coin: " coin <- getLine let ls = name:model:color:year:price:coin:[cars] putStrLn (show ls)