だから私は、次の機能があります。このエラーとともにのいずれかを使用して正しく
chk2 :: [(Integer,Integer)] -> Either [(Integer,Integer)] (Integer,Integer)
chk2 [email protected]((n,_):_)
| chkp (prod $ lgst i)==True = Right $ lgst i
| lgst i==i!!0 = Left $ chk2 $ (4-2,4-2):next i
| otherwise = Left $ chk2 $ next i
where prod (a,b) = a*b
lgst = foldl1 (\(a,b) (c,d) -> if prod (a,b) > prod (c,d) then (a,b) else (c,d))
next t = map (\(a,b) -> if (a,b)==lgst t then (a-1,b+1) else (a,b)) t
:私は(で終わるのいずれかに、この機能を取得しようとしている
runhugs: Error occurred
ERROR "4/4.hs":14 - Type error in explicitly typed binding
*** Term : chk2
*** Type : [(Integer,Integer)] -> Either (Either [(Integer,Integer (Integer,Integer)) (Integer,Integer)
*** Does not match : [(Integer,Integer)] -> Either [(Integer,Integer)] (Integer,Integer)
を、 b)すなわち第1のガードまたは[(a、b)]、すなわち後者の2つのガード。後者の2つのガードには基本的な問題があります。再帰を取り除くとすべてうまくいきますが、関数自体を返すときに型シグネチャを定義する方法がわかりません。
ペーストビンが悪い質問をします。将来に役立つために質問は自己完結型でなければなりません。 – Flexo
ちょうどawoodlandと同じように言っていた。今回はコードを貼り付けました。 – houbysoft
@Chris Bolton:ここで何を解決しようとしていますか? –