<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi Henry,<br>
<br>
I'm not sure if this is suitable for your use case, but maybe
simple multi parameter type classes would be an alternative?
Especially because then you could use FunDeps if more dependencies
turn up. Like this:<br>
</p>
<pre>
class Game gameState command mutable static | gameState -> mutable,static where
toGameId :: static -> GameId
toMutable :: gameState -> IO (Maybe mutable)
everyone :: mutable -> [Sink]
instance Game Chess ChessCommand ChessMutable ChessStatic where
…
</pre>
<p>Admittedly, the type looks a bit long. But maybe more unification
is possible to reduce that.<br>
</p>
<p>Yet another idea is that instead of sprinkling TypeApplications,
you could also try a bit of refactoring:<br>
</p>
<pre>
class Game g where
data Command g :: *
data Mutable g :: *
data Static g :: *
toGameId :: g -> GameId
toMutable :: g -> IO (Maybe (Mutable a))
everyone :: Mutable g -> [Sink]
instance Game Chess where
data Command Chess = MovePiece { movedPiece :: ChessField, moveTarget :: ChessField }
| Castling { withLeftRook :: Bool }
| Promote { promotedPiece :: ChessField, promotedTo :: ChessPiece }
| EnPassant { enPassantFrom :: ChessField }
| GiveUp
…
</pre>
</body>
</html>