小编Maf*_*afi的帖子

Haskell - fmap fmap不起作用

我正在使用GHCi(版本6.12.3)与Haskell一起玩.我最近阅读了有关仿函数和应用仿函数的想法,如果你不能<*>使用仿函数的原语来实现类似于applicative仿函数的东西.经过一番思考后我想出了fmap fmap一个(几乎)理想的类型

Functor f => f (a -> b) -> f (f a -> f b) 或者更一般地说

(Functor f1, Functor f2) => f1 (a -> b) -> f1 (f2 a -> f2 b)

我试过了

let q = fmap fmap
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

<interactive>:1:8:
    Ambiguous type variable `f1' in the constraint:
      `Functor f1' arising from a use of `fmap' at <interactive>:1:8-16
    Probable fix: add a type signature that fixes these type variable(s)

<interactive>:1:13:
    Ambiguous type variable `f' in the …
Run Code Online (Sandbox Code Playgroud)

haskell types ghci

5
推荐指数
1
解决办法
548
查看次数

标签 统计

ghci ×1

haskell ×1

types ×1