[Haskell-cafe] Help mixing pure and IO code

Bulat Ziganshin bulat.ziganshin at gmail.com
Sun Nov 29 09:41:13 EST 2009

Hello papa,

Sunday, November 29, 2009, 5:11:23 PM, you wrote:

> add some IO on top of it, keeping the main code pure. The idea was to
> write a very simple two-player game, then define some strategies to
> play it that do not involve IO

ho i could do it:

class Strategy state where
  initState :: state
  nextMove :: state -> (Move,state)
  updateState :: (Move,state) -> state

where initState gives initial state,
nextMove returns move and updated internal state
updateState updates state with opponent's move

then you can develop any IO front-end that runs two strategies each
against other

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list