Created
May 28, 2016 21:28
-
-
Save j1r1k/f5c8d8fdc211f60e28544f152bf036b2 to your computer and use it in GitHub Desktop.
PureScript by Example: Chapter 12 (Callback Hell) exercise 12.8.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ParallelConcat where | |
import Prelude (Unit, (<<<), ($), bind) | |
import Types (Async) | |
import Control.Monad.Except.Trans (ExceptT, mapExceptT) | |
import Control.Parallel (inParallel, runParallel) | |
import Data.Foldable (fold) | |
import Data.Traversable (class Traversable, traverse) | |
import Files (ErrorCode, FilePath, FS, readFileContEx, writeFileContEx) | |
concatenateMany :: forall eff t. Traversable t => t FilePath -> FilePath -> ExceptT ErrorCode (Async (fs :: FS | eff)) Unit | |
concatenateMany srcs trg = do | |
c <- mapExceptT runParallel $ traverse (mapExceptT inParallel <<< readFileContEx) srcs | |
writeFileContEx trg (fold c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment