Type compatibility means that one function returns a value another function can accept. It keeps function pipelines connected: for example, trim returns a String, and normalize accepts a String. JavaScript is loosely typed, so compatibility often depends on how a value behaves in practice rather than on declared type information. section 4.2
trim :: String -> String #1 normalize :: String -> String #2
Read the function signatures as a compact compatibility check: String -> String shows that both functions accept and return strings. section 4.2
Cleaning a Social Security number
const trim = (str) => str.replace(/^\s*|\s*$/g, ''); const normalize = (str) => str.replace(/\-/g, ''); normalize(trim(' 444-44-4444 ')); // '444444444' trim produces a String, so normalize can receive its result. The same idea lets an isValid function receive the normalized String and return a Boolean. section 4.2


