Answer the question
In order to leave comments, you need to log in
How easy is it to implement reading/writing files in Haskell?
I need to create a database (for educational purposes) in Haskell. I can’t figure out how to implement data entry through the console with further saving to a file, as well as reading data from the generated file. There is little clear (in my opinion) literature on Haskell on the Internet, can you tell me where you can see examples of such constructions. Thanks in advance, don't kick too much :)
Answer the question
In order to leave comments, you need to log in
Quite simply (very simplistic)
module Main where
import System.IO
main :: IO ()
main = do
content <- readFile "file.dat"
putStrLn content
putStr "enter x = "
-- Флюшим вывод не забываем про ленивость языка
hFlush stdout
x <- getLine
print (read x :: Int)
writeFile "file.dat" x
Need this --> For a comprehensive tutorial on using IO monad, look at the Haskell I/O inside: Down the Rabbit's Hole
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question