Skip to content

Instantly share code, notes, and snippets.

@jferris
Created April 2, 2015 20:50
Show Gist options
  • Save jferris/4df29545f5fce74064ac to your computer and use it in GitHub Desktop.
Save jferris/4df29545f5fce74064ac to your computer and use it in GitHub Desktop.
on
> let a = [1]
> let b = [2]
> a + b
<interactive>:5:1:
No instance for (Num [t0]) arising from a use of ‘it’
In a stmt of an interactive GHCi command: print it
> (on (+) head) a b
3
@r00k
Copy link

r00k commented Apr 2, 2015

on :: (b -> b -> c) -> (a -> b) -> a -> a -> c

@r00k
Copy link

r00k commented Apr 2, 2015

Reads quite nicely infix:

((+) `on` head) a b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment