相关疑难解决方法(0)

Haskell($)是一个神奇的算子?

说我有以下功能:

infixr 0 <|

{-# INLINE (<|) #-}
(<|) :: (a -> b) -> a -> b
f <| x = f x

foo :: a -> (forall b. b -> b) -> a
foo x f = f x
Run Code Online (Sandbox Code Playgroud)

以下不进行类型检查:

ghci> foo 3 <| id

Couldn't match expected type `forall b. b -> b'
            with actual type `a0 -> a0'
In the second argument of `(<|)', namely `id'
In the expression: f 3 <| id
In an equation for …
Run Code Online (Sandbox Code Playgroud)

haskell

54
推荐指数
1
解决办法
1631
查看次数

标签 统计

haskell ×1