Safe Haskell | Safe |
---|
Ship
Description
This trusted module defines the datatype of ships, along with associated functions.
Documentation
data Ship
The ships.
Constructors
Carrier | The carrier. |
Battleship | The battleship. |
Submarine | The submarine. |
Destroyer | The destroyer. |
PatrolBoat | The patrol boat. |
Number of cells in a ship:
size
Carrier
= 5size
Battleship
= 4size
Submarine
= 3size
Destroyer
= 3size
PatrolBoat
= 2
Description of a ship (first letters must be distinct and in lowercase):
shipToStr
Carrier
= "carrier"shipToStr
Battleship
= "battleship"shipToStr
Submarine
= "submarine"shipToStr
Destroyer
= "destroyer"shipToStr
PatrolBoat
= "patrol boat"
shipToLetter :: Ship -> Char
First letter of ship's description.