생성자는 항상 그 클래스의 새 인스턴스를 돌려준다. 생성자를 private 으로 막고 static create 를 두면 셋을 할 수 있다: 유효성 검사에 실패하면 null(또는 Result)을 돌려주고(이름이 3자 미만이면 null), 인자에 따라 다른 하위 클래스를 돌려주고(circle 이면 Circle, rect 면 Rectangle), 이미 있는 인스턴스를 돌려준다(싱글톤). 단순 초기화만 필요하면 생성자가 더 직관적이다.

-- 생성자는 항상 새 인스턴스를 준다. private 생성자 + static create 면 셋이 된다
create :: String -> Maybe User           -- 1 실패를 값으로 (null / Result)
create name | length name < 3 = Nothing
            | otherwise       = Just (User name)

shape :: Kind -> Size -> Shape           -- 2 하위 클래스를 고른다 (팩토리)
shape Circle = circle
shape Rect   = rectangle

config :: IO Config                      -- 3 같은 인스턴스 (싱글톤): instance ??= new Config()
config = readIORef instanceRef >>= maybe (newConfig >>= cache) pure
-- 단순 초기화만이면 생성자가 더 직관적
`#381`