Files
loop/src/Dodge/LoadSeed.hs
T
2025-10-04 09:53:33 +01:00

18 lines
415 B
Haskell

module Dodge.LoadSeed where
import Data.Functor
import System.Directory
import Text.Read
loadSeed :: IO (Maybe Int)
loadSeed = maybeReadFile "generated/saves/seed" <&> (>>= readMaybe)
maybeReadFile :: String -> IO (Maybe String)
maybeReadFile fpath = do
fexists <- doesFileExist fpath
if fexists
then do
str <- readFile fpath
return (Just str)
else return Nothing