I am wiriting simple application which has functionality of saving/loading its current state. Save function looks as below:
doSave :: BoardType -> Field -> [Char] -> Bool
doSave board player fileName = do
let x = encodeFile fileName (board :: BoardType, player :: Field)
True -- there will be exception handling
And my load function:
doLoad :: [Char] -> IO (BoardType, Field)
doLoad fileName = decodeFile fileName :: IO (BoardType, Field)
And there's my problem, after loading, I have IO (BoardType, Field)
which does not fit my program and other functions which probably should not accept IO
parameters. If I have followed this IO
escalation, there would be all IO
s in my application - is it necessary (or - normal in haskell language)?
And finally - is there a simple way I can get rid of this IO
?