Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Nit, but a single | can't be an operator in Haskell.


True, I got that piece of the syntax wrong.

I guess you can do something very close, though.


Haskell has `&` in Data.Function. You can try it in ghci:

  Prelude> f a x = a * x
  Prelude> g x = x + 2
  Prelude> g $ f 3 $ 5
  17
  Prelude> :m +Data.Function
  Prelude Data.Function> 5 & f 3 & g
  17
It is like `$` but with the arguments flipped:

  ($) :: (a -> b) -> a -> b
  (&) :: a -> (a -> b) -> b


Absolutely. Almost every group of symbols can be used as an operator, just (as it happens) not a single | because that is reserved for patterns.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: