In Javascript, the replace function when the first parameter is a Regex, there are special character strings for replacements, e.g. $'.
The problem is that the PureScript replaceAll relies on the JavaScript replace using a Regex with the global flag.
This means that replacement strings are simple string replacements, but instead are interpreted.
Suggested fix:
export const replaceAll = p => r => s => s.replace(new RegExp(p.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"), "g"), r.replace(/\$/g, "$$$$")); // eslint-disable-line no-useless-escape
We're replacing the $ with $$ globally in the replacement string.