Hola! Hallo!My question are:
I made my first program to understand lists and something about datat types. I have some question about the following code...
import Data.List data Student = Student { id :: Int, nombre :: String } deriving (Show, Eq) main :: IO () main = do putStrLn "---\nStudent Magnament Program\n---" loop [] ashow :: [Student] -> IO () ashow [] = putStrLn "Empty list" ashow [x] = putStrLn $ show x ashow (x:xs)= do putStrLn $ show x ashow xs aadd :: [Student] -> IO () aadd xs = do putStrLn "Enter the id" id <- getLine putStrLn "Enter name" name <- getLine loop $ (Student (read id) (read name) ) : xs aremove :: [Student] -> IO () aremove xs = do putStrLn "Enter the id" id <- getLine putStrLn "Enter name" name <- getLine loop $ delete (Student (read id) (read name) ) xs loop :: [Student] -> IO () loop xs = do putStr $ "\n-------\nSelect an option\n" ++ "1) Add student\n" ++ "2) Remove student\n" ++ "3) Show all students\n" ++ "4) Exit\n" ++ "\t Your option: " option <- getLine putStrLn "\n------" case read option of 1 -> aadd xs 2 -> aremove xs 3 -> do ashow xs loop xs 4 -> putStrLn "God bye!"
Sorry for my bad english, i am Argentinean.
Thanks in advance.