0
또 다른 기본적인 문제가 있습니다. 나는 ghci를 사용하고있다.Basic Haskell : 함수 문제
는 I (도움)이 작업 코드를 생성 :
newtype Name = Name String deriving (Show)
newtype Age = Age Int deriving (Show)
newtype Weight = Weight Int deriving (Show)
newtype Person = Person (Name, Age, Weight) deriving (Show)
isAdult :: Person -> Bool
isAdult (Person(_, Age a, _)) = a > 18
그러나 나는 그것이 이전 값의에서 사용자가 사람의 무게를 변경할 수있는 더 복잡한 기능 updateWeight을 시도 할 때 문제가 발생합니다. 제가 잘못한 곳을 지적 해 주시겠습니까?
updateWeight :: Person -> Int -> Person
updateWeight (Person(_,_,Weight w) b = (Person(_,_,w+b))
어제의 답변을 수락 할 수 있습니까? :) –