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