How do one define this point-free?
let argmax m = (fst.(maximumBy (comparing snd)).(zip [0..])) m
which works as expected.
The most logical seems to just drop the m like this:
let argmax = (fst.(maximumBy (comparing snd)).(zip [0..]))
Works to define in ghci, but calling it with argmax [1,3,4,5,6,1] gives me
<interactive>:103:9:
No instance for (Num ())
arising from the literal `1'
Possible fix: add an instance declaration for (Num ())
In the expression: 1
In the first argument of `argmax', namely `[1, 3, 4, 5, ....]'
In the expression: argmax [1, 3, 4, 5, ....]
I think it has to do with the types:
:t (fst.(maximumBy (comparing snd)).(zip [0..]))
:: (Enum c, Num c, Ord a) => [a] -> c
for the point version:
argmax :: (Enum c, Num c, Ord a) => [a] -> c
for the point-free version:
argmax :: [()] -> Integer
Is this a ghci spookiness or am I doing something wrong?