18 lines
408 B
Haskell
18 lines
408 B
Haskell
module Dodge.LoadSeed where
|
|
|
|
import Data.Functor
|
|
import System.Directory
|
|
import Text.Read
|
|
|
|
loadSeed :: IO (Maybe Int)
|
|
loadSeed = maybeReadFile "saveSlot/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
|