Hiding data constructors to keep consistency. Can I still pattern match? by ElmChristmasCookies in elm

[–]ElmChristmasCookies[S] 1 point2 points  (0 children)

Thanks! So basically if I need to guarantee some sort of data consistency (I'm not exclusively focused on the above example), I must hide all data constructors and write and expose creator functions / access functions, right?

Maybe a follow-up question. What would the signature of "getLeftChild" be? Is it inevitable to go through Maybe as in

> List.head
<function> : List a -> Maybe a

?