Skip to content

fixing Waltz of the Types first example#606

Open
dotnetCarpenter wants to merge 1 commit intoMostlyAdequate:masterfrom
dotnetCarpenter:fix_ch12_partII
Open

fixing Waltz of the Types first example#606
dotnetCarpenter wants to merge 1 commit intoMostlyAdequate:masterfrom
dotnetCarpenter:fix_ch12_partII

Conversation

@dotnetCarpenter
Copy link
Copy Markdown
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
Copy Markdown
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.

1 participant