Last active
February 13, 2019 19:20
-
-
Save dwhitney/f7e8488025f517be7e6f05de85ade3b4 to your computer and use it in GitHub Desktop.
map join a traverse - illustration for a reddit question https://www.reddit.com/r/purescript/comments/aq31gu/i_feel_like_this_is_probably_a_standard_function/
This file contains 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 Main where | |
import Prelude | |
import Data.Array (range) as Array | |
import Data.Traversable (traverse) | |
import Effect.Aff (Aff) | |
combineABunchOfArrays :: Aff (Array Int) | |
combineABunchOfArrays = | |
traverse makeArray (Array.range 0 10) # map join | |
combineABunchOfArrays2 :: Aff (Array Int) | |
combineABunchOfArrays2 = | |
join <$> traverse makeArray (Array.range 0 10) | |
makeArray :: Int -> Aff (Array Int) | |
makeArray num = pure $ Array.range 0 num |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment