다형성 트리 유형에 대해 Show 함수를 정의하려고합니다. 누구든지 나를 도울 수 있을까?다형성 유형에 대한 함수 표시
import Char
data Tree t =
NilT |
Node t (Tree t) (Tree t)
class Mar t where
maior :: t -> String
instance Mar Tree where
maior (NilT) = "a"
maior (Node t a b) = "b"
instance Show Tree where
show = maior
고마워요! (ivanm에 의해 주어진)
솔루션 :
import Char
data Tree t =
NilT |
Node t (Tree t) (Tree t)
class Mar t where
maior :: t -> String
instance Mar (Tree t) where
maior (NilT) = "a"
maior (Node t a b) = "b"
instance Show (Tree t) where
show = maior
샷을 주셔서 감사합니다,하지만 여전히 내게 같은 오류 (당신이 언급 한 하나) =/ – Filipe
내 나쁜 일을 !!! 매우 감사합니다!!! – Filipe