diff --git a/package.yaml b/package.yaml index d8947f8..261497c 100644 --- a/package.yaml +++ b/package.yaml @@ -23,6 +23,7 @@ dependencies: - base >= 4.7 && < 5 - containers - haskeline +- parallel - text - transformers diff --git a/src/Jotto.hs b/src/Jotto.hs index 0dd3143..6db11fb 100644 --- a/src/Jotto.hs +++ b/src/Jotto.hs @@ -21,11 +21,12 @@ module Jotto , nextGuesses ) where -import Data.List import Data.Char +import Data.List -import qualified Data.Map as M -import qualified Data.Set as S +import Control.Parallel.Strategies +import qualified Data.Map as M +import qualified Data.Set as S data Guess = Guess String Int deriving (Show) @@ -160,7 +161,7 @@ nextGuesses g = lpwords = M.map length $ pwords pclasses = M.keysSet pwords options1 = M.assocs $ allWords g - options2 = map (\(set, w) -> (set, worstCase set lpwords, w)) options1 + options2 = parMap rdeepseq (\(set, w) -> (set, worstCase set lpwords, w)) options1 options3 = sortOn (\(_,_,w) -> length w) options2 options4 = sortOn (\(s,_,_) -> S.member s pclasses) options3 options5 = sortOn (\(_,c,_) -> c) options4