相关疑难解决方法(0)

解析f = f(<*>)pure的类型

最近我注意到,幽默地liftA可以写成

liftA (<*>) pure
Run Code Online (Sandbox Code Playgroud)

我认为这很整洁,所以开个玩笑,我想我将liftA基于此属性做出新的“定义” :

f = f (<*>) pure
Run Code Online (Sandbox Code Playgroud)

现在,我曾期望这与liftA从未停止过的事情属于同一类型。但是,它无法编译。

• Occurs check: cannot construct the infinite type:
    t ~ (f (a -> b) -> f a -> f b) -> (a1 -> f1 a1) -> t
• In the expression: f (<*>) pure
  In an equation for ‘f’: f = f (<*>) pure
• Relevant bindings include
    f :: (f (a -> b) -> f a -> f b) -> (a1 …
Run Code Online (Sandbox Code Playgroud)

haskell types typechecking applicative

9
推荐指数
1
解决办法
140
查看次数

标签 统计

applicative ×1

haskell ×1

typechecking ×1

types ×1