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

Conversation

dotnetCarpenter
Copy link
Contributor

By using the improved traverse function from #581 (comment)
and adding toString since the nodejs fs.readFile returns a Buffer and not a String.

// readFile :: FileName -> Task Error String

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

// tldr :: FileName -> Task Error String
const tldr = compose(map(firstWords), readFile);

traverse(Task.of, tldr, ['file1', 'file2']);
// Task(['hail the monarchy', 'smash the patriarchy']);

Before the traverse function threw a TypeError: f.traverse is not a function, on traverse(Task.of, tldr, ['file1', 'file2']);.

Thanks to @antonklimov.

By using the improved `traverse` function from MostlyAdequate#581 (comment)
and adding `toString` since the nodejs `fs.readFile` returns a Buffer and not a String.
@dotnetCarpenter
Copy link
Contributor Author

Blocks #607

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant