誰にもこのコードが失敗する理由は分かりますか?haskell - 奇数型の不明確な型の変数のエラーメッセージ "where"文(TypeFamilies拡張子付き)
{-# LANGUAGE NoMonomorphismRestriction,
TypeFamilies #-}
module Test where
asExprTyp :: Expr γ =>
γ α
-> α
-> γ α
asExprTyp x _ = x
int = undefined :: Integer
class Expr γ where
a :: γ α
-- this works fine
b = a `asExprTyp` int
-- this fails
mcode = do
return()
where b = a `asExprTyp` int
次のようにエラーが、私はHaskellでタイプ・ファミリーを使ったことがないので、さて、これは私の頭の上にややある、
Test.hs:23:15:
Ambiguous type variable `γ0' in the constraint:
(Expr γ0) arising from a use of `a'
Probable fix: add a type signature that fixes these type variable(s)
In the first argument of `asExprTyp', namely `a'
In the expression: a `asExprTyp` int
In an equation for `b': b = a `asExprTyp` int
Failed, modules loaded: none.
ここに問題はありません。 'b'が失敗した表現にどのようなタイプがあると思いますか? –
@JohnL: 'b :: Exprγ=>γ整数' – mergeconflict
@mergeconflict:それは完全に合理的です。私はγを関連タイプと考えていましたが、それは間違いなくあります。 –