15

Tried to use (.) for function composition, but it doesn't work.

import Data.String (length, trim)

trimmedLength :: String -> Int
trimmedLength = length . trim
dontexist
  • 5,252
  • 4
  • 27
  • 51

1 Answers1

17

Function composition in PureScript is done with (<<<), not (.).

import Data.String (length, trim)

trimmedLength :: String -> Int
trimmedLength = length <<< trim
dontexist
  • 5,252
  • 4
  • 27
  • 51
  • That's verbose. Doesn't puresript supports unicode and hence could have `∘`? –  Sep 16 '17 at 12:04
  • 1
    Yes, it's just not included in the core `Prelude`. Project-specific preludes will often define this if they're in unicode-friendly projects. – gb. Sep 16 '17 at 13:11
  • As of a couple of minutes ago, there's a library that (so far) does only this - [purescript-gorgeous](https://github.com/slamdata/purescript-gorgeous) - although it's not published on Pursuit yet. – dontexist Sep 16 '17 at 19:44