From fc6cf6169868e60c189e4b243330c3717ff159f3 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 26 May 2022 13:58:07 +0200 Subject: ... --- overlays/spm/server/Spm/Server/Wordlist.hs | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 overlays/spm/server/Spm/Server/Wordlist.hs (limited to 'overlays/spm/server/Spm/Server/Wordlist.hs') 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 @@ +{-# LANGUAGE TemplateHaskell #-} + +module Spm.Server.Wordlist + ( wordlist, consonants + ) where + +import Prelude +import Language.Haskell.TH.Syntax +import Control.Monad.IO.Class + +import Data.Text (Text) +import qualified Data.Text as Text +import qualified Data.Text.IO as Text + +import Data.Vector (Vector) +import qualified Data.Vector as Vector + +import Data.FileEmbed (makeRelativeToProject) + +import Instances.TH.Lift () + + +{-# NOINLINE wordlist #-} +{-# NOINLINE consonants #-} +wordlist, consonants :: Vector Text +wordlist = $( do + fPath <- makeRelativeToProject "wordlist.txt" + addDependentFile fPath + lift . Vector.fromList =<< liftIO (filter (not . Text.null) . Text.words <$> Text.readFile fPath) + ) +consonants = Vector.fromList $ map Text.singleton "bcdfghjklmnpqrstvwxz" -- cgit v1.2.3