以下是我沒有嘗試提取b
的TypeRef
的TypeRef:獲取函數結果類型
import Data.Typeable
f :: Typeable b => a -> b
f = impl
where
bTypeRep = typeOf $ (undefined :: Typeable b => (a -> b) -> b) impl
impl = undefined
的錯誤消息如下:
Could not deduce (Typeable a0) arising from a use of `typeOf'
from the context (Typeable b)
bound by the type signature for f :: Typeable b => a -> b
at src/Xet.hs:14:6-25
The type variable `a0' is ambiguous
有什麼不對?如何解決這個問題?
查找到'ScopedTypeVariables' – luqui
@luqui你快) –