[英]How can I manually calculate the type of functions with class constraints?
[英]How I can calculate the type of (> 0)?
每當我有一個部分應用其左參數的運算符部分時,即:
(0 >)
我只是簡單地以前綴形式重寫運算符並繼續計算:
(>) 0
如何計算部分應用其正確參數的運算符部分的類型?
對於(>)
,沒關系,因為兩個參數具有相同的類型。 從Ord a => a -> a -> Bool
中刪除Ord a => a
,剩下的就是Ord a => a -> Bool
。
通常,您只需刪除與應用參數對應的類型。 例如,給定(??) :: Int -> Char -> Bool
,
-- with the Int argument supplied, you still need a Char
(x ??) == (\y -> x ?? y) :: Char -> Bool
-- with the Char argument supplied, you still need an Int
(?? y) == (\x -> x ?? y) :: Int -> Bool
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.