Use Data.Map on streaming side as well

This commit is contained in:
Mats Rauhala 2021-10-29 17:26:29 +03:00
parent 87f6eb00f6
commit e189f87dd7

View File

@ -17,7 +17,7 @@ import System.IO
import qualified Data.Foldable as F
import qualified Data.Trie as Trie
import qualified Data.Map.Strict as Map
import Data.Maybe
(fromMaybe)
@ -36,7 +36,7 @@ run = do
datDir <- fromMaybe "./" <$> lookupEnv "HOME"
runResourceT $ do
x <- runConduit stream
runConduit (CL.sourceList (Trie.keys x) .| C.map (<> "\n") .| CB.sinkFileCautious (datDir </> ".addressbook.dat"))
runConduit (CL.sourceList (Map.keys x) .| C.map (<> "\n") .| CB.sinkFileCautious (datDir </> ".addressbook.dat"))
where
separate = \case
From x -> [x]
@ -49,4 +49,4 @@ run = do
.| combine
.| C.concatMap separate
.| CT.encode CT.utf8
.| C.foldMap (`Trie.singleton` ())
.| C.foldMap (`Map.singleton` ())