1 {-# OPTIONS_GHC -Wall #-}
2 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
7 newtype Score = Score Int
8 deriving (Eq, Ord, Show, Num)
10 getScore :: Score -> Int
11 getScore (Score i) = i
13 instance Monoid Score where
17 -- tile scoring rules as in http://www.thepixiepit.co.uk/scrabble/rules.html
18 score :: Char -> Score
19 score c | c `elem` "aeilnorstuAEILNORSTU" = 1
21 | c `elem` "bcmpBCMP" = 3
22 | c `elem` "fhvwyFHVWY" = 4
25 | c `elem` "qQzZ" = 10
28 scoreString :: String -> Score
29 scoreString s = foldr mappend mempty (map score s)