News for hackers. Stuff that matters.
Re:Inventing Monads by smegma2 on Sunday August 30, 2020 @12:51PM (#24324019)
`on` runs a binary function by first running a unary function on each argument.

  Prelude> import Data.Function (on)
  Prelude Data.Function> :t on
  on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
  Prelude Data.Function> f = undefined :: Int -> [Int]
  Prelude Data.Function> g = undefined :: Int -> [Int]
  Prelude Data.Function> :t ((&&) `on` (not . null . ($ x))) f g
  ((&&) `on` (not . null . ($ x))) f g :: Bool
Alternatively in Control.Arrow there's a 'fanout' operator &&&:

  Prelude Control.Arrow> f = undefined :: Int -> Bool
  Prelude Control.Arrow> g = undefined :: Int -> Bool
  Prelude Control.Arrow> :t uncurry (&&) . (f &&& g)
  uncurry (&&) . (f &&& g) :: Int -> Bool
Of course it's still probably simpler to just write it out in this case.
Re:Inventing Monads by codygman on Sunday August 30, 2020 @04:05PM (#24325505)