Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing Waltz of the Types first example #606

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
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