为什么(-1)
的情况不适用于此:
λ> (+1) <$> Right 10
Right 11
Prelude
λ> (-1) <$> Right 10
<interactive>:22:1: error:
• Non type-variable argument in the constraint: Num (a -> b)
(Use FlexibleContexts to permit this)
• When checking the inferred type
it :: forall a b a1. (Num (a -> b), Num a) => Either a1 b
Prelude
λ> (*1) <$> Right 10
Right 10
Prelude
λ> (/1) <$> Right 10
Right 10.0
Prelude
λ>
答案 0 :(得分:3)
它将(-1)
解释为-1
而不是((-) 1)
尝试((-) 1) <$> Right 10