
There is a little exercise at the end of the post "Type Tac Toe: Advanced Type Safety" http://chrispenner.ca/posts/type-tac-toe
As an exercise try combining playX and playO into a more general play! Here's a hint, you'll want to make another wrapper type like we did with Coord!
Link to the code https://github.com/ChrisPenner/Type-Tac-Toe/blob/master/src/TypeTacToe.hs Unfortunately I couldn't solve it by myself. The only generalised play I could implement is here: play :: (Played x y b ~ 'False) => (Coord x, Coord y) -> Board b PieceT -> PieceT -> Board b PieceT play (coordVal -> x, coordVal -> y) (Board b) p = Board $ overTrip y (overTrip x (const p)) b I would be very grateful for any help to solve the exercise by using type family extension. Regards, Alexei
participants (1)
-
info@maximka.de