type Name = String
lowerName :: Name -> Name
lowerName = map toLower
-- then:
lowerName "KELAN" -- evaluates to "kelan"
####
data Piece = Pawn | Rook | Knight | Bishop | Queen | King
-- The type is 'Piece', and to construct an actual value of
-- that type, you use one of the six data constructors.
promotesTo :: Piece -> [Piece]
promotesTo Pawn = [ Rook, Knight, Bishop, Queen ]
promotesTo _ = []
-- then:
promotesTo Pawn -- evaluates to [Rook, Knight, Bishop, Queen]
promotesTo $ head $ promotesTo Pawn -- evaluates to []
####
data Rectangle
= UnitSquare
| Square Int
| Rect Int Int
-- examples of values for each would be:
v1 :: Rectangle
v1 = UnitSquare
v2 :: Rectangle
v2 = Square 3
v3 :: Rectangle
v3 = Rect 5 9