summaryrefslogtreecommitdiff
path: root/overlays/spm/server/Spm/Server/Wordlist.hs
diff options
context:
space:
mode:
Diffstat (limited to 'overlays/spm/server/Spm/Server/Wordlist.hs')
-rw-r--r--overlays/spm/server/Spm/Server/Wordlist.hs31
1 files changed, 31 insertions, 0 deletions
diff --git a/overlays/spm/server/Spm/Server/Wordlist.hs b/overlays/spm/server/Spm/Server/Wordlist.hs
new file mode 100644
index 00000000..8109f07b
--- /dev/null
+++ b/overlays/spm/server/Spm/Server/Wordlist.hs
@@ -0,0 +1,31 @@
1{-# LANGUAGE TemplateHaskell #-}
2
3module Spm.Server.Wordlist
4 ( wordlist, consonants
5 ) where
6
7import Prelude
8import Language.Haskell.TH.Syntax
9import Control.Monad.IO.Class
10
11import Data.Text (Text)
12import qualified Data.Text as Text
13import qualified Data.Text.IO as Text
14
15import Data.Vector (Vector)
16import qualified Data.Vector as Vector
17
18import Data.FileEmbed (makeRelativeToProject)
19
20import Instances.TH.Lift ()
21
22
23{-# NOINLINE wordlist #-}
24{-# NOINLINE consonants #-}
25wordlist, consonants :: Vector Text
26wordlist = $( do
27 fPath <- makeRelativeToProject "wordlist.txt"
28 addDependentFile fPath
29 lift . Vector.fromList =<< liftIO (filter (not . Text.null) . Text.words <$> Text.readFile fPath)
30 )
31consonants = Vector.fromList $ map Text.singleton "bcdfghjklmnpqrstvwxz"