Haskell 部分应用函数类型的函子

Haskell 部分应用函数类型的函子,haskell,functor,Haskell,Functor,Haskell的编程中有一个问题是: 填写以下声明: instance Functor ((->) a) where 现在,作为函子,Thing有一个类型定义: instance Functor Thing where --fmap::(a -> b) -> Thing a -> Thing b 我想知道这种减少是否有意义: instance Functor ((->) a) where -- fmap::(a -> b) ->

Haskell的编程中有一个问题是: 填写以下声明:

instance Functor ((->) a) where
现在,作为函子,Thing有一个类型定义:

instance Functor Thing where    
   --fmap::(a -> b) -> Thing a -> Thing b 
我想知道这种减少是否有意义:

instance Functor ((->) a) where
    -- fmap::(a -> b) -> ((->) a) a -> ((->) a) b 
    -- therefore
    -- fmap::(a -> b) -> a -> a -> (a -> b) 
    -- therefore
    -- fmap::b -> b
--更新--- 我错过了括号,应该是的

instance Functor ((->) a) where
    -- fmap::(a -> b) -> ((->) a) a -> ((->) a) b 
    -- therefore
    -- fmap::(a -> b) -> (a -> a) -> (a -> b) 
    -- therefore
    -- I should be returning a function of a -> b

否,因为实例声明中的
a
fmap
类型中的
a
不同。您需要在实例声明中指定一个类型变量,以避免
fmap
类型中的
a

instance Functor ((->) r) where
  fmap :: (a -> b) -> (r -> a) -> (r -> b)

谢谢你,雷恩!为了澄清我的理解:从:fmap(+1)(show)返回的部分函数将取3并返回“4”?否,但
fmap show(+1)
将取
3并返回
“4”
<代码>fmap
这里是
()