मैं निम्नलिखित समारोह लिखा है:जीएचसी एसटी मोनैड कोड को टाइप वैरिएबल को एकीकृत करने में असमर्थ के रूप में अस्वीकार करता है?
(.>=.) :: Num a => STRef s a -> a -> Bool
r .>=. x = runST $ do
v <- readSTRef r
return $ v >= x
लेकिन जब मैं संकलन करने की कोशिश की मैं निम्नलिखित त्रुटि मिली:
Could not deduce (s ~ s1)
from the context (Num a)
bound by the type signature for
.>=. :: Num a => STRef s a -> a -> Bool
at test.hs:(27,1)-(29,16)
`s' is a rigid type variable bound by
the type signature for .>=. :: Num a => STRef s a -> a -> Bool
at test.hs:27:1
`s1' is a rigid type variable bound by
a type expected by the context: ST s1 Bool at test.hs:27:12
Expected type: STRef s1 a
Actual type: STRef s a
In the first argument of `readSTRef', namely `r'
In a stmt of a 'do' expression: v <- readSTRef r
किसी को भी मदद कर सकते हैं?
नोट अभी भी चेक टाइप नहीं करेगा, क्योंकि बाधा 'ऑर्ड' होनी चाहिए, न कि 'न्यू'। – hammar
इसे तलाशने के लिए धन्यवाद। – dave4420