考虑Haskell(GHC)中的隐式参数,我遇到了问题.我有一个函数f,它假定隐含参数x,并希望通过将f应用于g来将其封装在上下文中
f :: (?x :: Int) => Int -> Int
f n = n + ?x
g :: (Int -> Int) -> (Int -> Int)
g t = let ?x = 5 in t
Run Code Online (Sandbox Code Playgroud)
但是当我试图评估时
g f 10
Run Code Online (Sandbox Code Playgroud)
我得到一个x没有绑定的错误,例如:
Unbound implicit parameter (?x::Int)
arising from a use of `f'
In the first argument of `g', namely `f'
In the second argument of `($)', namely `g f 10'
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我,我做错了什么?
(我试图让Haskell的WordNet接口工作 - …