수색…


함수 인수

type Dog = Dog String

dogName1 dog =
    case dog of
      Dog name ->
         name

dogName2 (Dog name) ->
     name

dogName1dogName2 는 동일합니다. 단일 생성자가있는 ADT에서만 작동합니다.

type alias Pet =
   { name: String
   , weight: Float
   
   }

render : Pet -> String
render ({name, weight} as pet) =
    (findPetEmoji pet) ++ " " ++ name ++ " weighs " ++ (toString weight)

findPetEmoji : Pet -> String
findPetEmoji pet = 
    Debug.crash "Implementation TBD"

여기서 우리는 레코드를 분해하고 또한 파손되지 않은 레코드에 대한 참조를 얻습니다.

단일 유형의 해체 된 주장

type ProjectIdType = ProjectId String

getProject : ProjectIdType -> Cmd Msg
getProject (ProjectId id) =
    Http.get <| "/projects/" ++ id


Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow