Commits

Luke Plant committed dc7d541

Some strictness annotations

This allows us to cope with a bigger dictionary, but still get Stack
Overflow eventually.

  • Participants
  • Parent commits a4c4277

Comments (0)

Files changed (1)

File phone2word.hs

+{-# LANGUAGE BangPatterns #-}
 {-
 Attempt to convert numbers like 01523 568304 into
 words/numbers, using the map used on most mobile
     then Just char
     else Map.lookup (toUpper char) numbersMap
 
-data WordTree = Node { nodeSubForest :: Map.Map Char WordTree -- children
-                     , nodeWords :: [B.ByteString]            -- words that correspond to this node
+data WordTree = Node { nodeSubForest :: !(Map.Map Char WordTree) -- children
+                     , nodeWords :: ![B.ByteString]              -- words that correspond to this node
                      } deriving (Eq, Read, Show)
 
 
         -> B.ByteString -- ^ whole word
         -> WordTree     -- ^ input tree
         -> WordTree
-addWord chars word tree =
+addWord !chars !word !tree =
     if B.null chars
        then tree { nodeWords = addWordToList word (nodeWords tree) }
        else let c = B.head chars