2
내가 유형 Foo
이 내가 GHCi에서 사용할 수 있도록, 그것을 Show
의 인스턴스를 만들고 싶어 : 나는 그것을 사용하려고하면인스턴스를 정의 할 때 모호한 오류가 발생하는 이유는 무엇입니까?
data Foo = Foo
instance Show Foo where
show Foo = "Foo"
을하지만, 나는 모호한 발생 오류 :
ghci> show Foo
<interactive>:4:1:
Ambiguous occurrence `show'
It could refer to either `Main.show', defined at Foo.hs:4:1
or `Prelude.show',
imported from `Prelude' at Foo.hs:1:1
(and originally defined in `GHC.Show')
왜? 방금 typeclass에 속하는 함수를 정의 했지?
참고 :이 질문은 [내 다른 하나와 유사] (https://stackoverflow.com/questions/35855170/why-shouldnt-i-mix-tabs-and-spaces)이며 최소 일반 사항입니다. 더 자주 묻는 하스켈 질문 중 하나의 변종. – Zeta