Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
pp:2023:haskell:l09 [2023/04/30 16:21] bogdan.deac |
pp:2023:haskell:l09 [2023/05/02 22:15] (current) bogdan.deac |
||
|---|---|---|---|
| Line 66: | Line 66: | ||
| **9.1.1** Let's implement a ''ChessResult'' data type. In chess, a game result can be either a Win, a Draw or a Loss. | **9.1.1** Let's implement a ''ChessResult'' data type. In chess, a game result can be either a Win, a Draw or a Loss. | ||
| <code haskell> | <code haskell> | ||
| - | data ChessResult = ??? deriving Show | + | data ChessResult = ??? |
| </code> | </code> | ||
| - | **9.1.2** We want to be able to print a ''ChessResult''. For this, we could do ''deriving Show'' to let GHC derive the implementation, but let's do it ourselves. | + | **9.1.2** We want to be able to show a ''ChessResult''. For this, we could do ''deriving Show'' to let GHC derive the implementation, but let's do it ourselves. |
| <code haskell> | <code haskell> | ||
| instance Show ChessResult where | instance Show ChessResult where | ||
| Line 104: | Line 104: | ||
| We also want to model a chess tournament. We'll represent it as a binary tree. | We also want to model a chess tournament. We'll represent it as a binary tree. | ||
| <code Haskell> | <code Haskell> | ||
| - | data player = Player { ??? } | + | data Player = Player { ??? } |
| data Tree a = ??? deriving Show | data Tree a = ??? deriving Show | ||
| type Tournament = Tree Player | type Tournament = Tree Player | ||