これが私のコードです:
getMove :: Board -> Player -> IO (Maybe (Move, Board, Player))
completeUserTurn :: Player -> Board -> Maybe (IO (Board, Player))
completeUserTurn player board = do
m <- getMove board player --error is here
if isNothing m then
Nothing
else do
let (move, updatedBoard, updatedPlayer) = fromJust m
if isMoveValid board move then do
continue <- prompt $ displayToUserForPlayer updatedBoard updatedPlayer ++ "\n" ++ "Is this correct? (y/n): "
if continue == "y" then
return (updatedBoard, updatedPlayer)
else
completeUserTurn player board
else do
putStr "Invalid Move!\n"
completeUserTurn player board
これが私が得ているエラーです(指定された行で):
Couldn't match expected type `Maybe t0'
with actual type `IO (Maybe (Move, Board, Player))'
In the return type of a call of `getMove'
In a stmt of a 'do' block: m <- getMove board player
In the expression:
do { m <- getMove board player;
if isNothing m then
Nothing
else
do { let ...;
.... } }
なにが問題ですか?私<-
はIOアクションを実行し、結果をmに入れると思いますか? なぜMaybe
then を期待するのですか?