Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ch12.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Let's get weird:
// readFile :: FileName -> Task Error String

// firstWords :: String -> String
const firstWords = compose(intercalate(' '), take(3), split(' '));
const firstWords = compose(intercalate(' '), take(3), split(' '), toString);

// tldr :: FileName -> Task Error String
const tldr = compose(map(firstWords), readFile);
Expand Down Expand Up @@ -149,7 +149,7 @@ Time to revisit and clean our initial examples.
// readFile :: FileName -> Task Error String

// firstWords :: String -> String
const firstWords = compose(intercalate(' '), take(3), split(' '));
const firstWords = compose(intercalate(' '), take(3), split(' '), toString);

// tldr :: FileName -> Task Error String
const tldr = compose(map(firstWords), readFile);
Expand Down
6 changes: 5 additions & 1 deletion support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,11 @@ const toUpperCase = s => s.toUpperCase();


// traverse :: (Applicative f, Traversable t) => (a -> f a) -> (a -> f b) -> t a -> f (t b)
const traverse = curry((of, fn, f) => f.traverse(of, fn));
const traverse = curry((of, fn, f) =>
Array.isArray(f)
? f.reduce((innerF, a) => fn(a).map(append).ap(innerF), of([]))
: f.traverse(of, fn)
);


// unsafePerformIO :: IO a -> a
Expand Down