-- 전화번호: 숫자만 남기고 (길이, 02 접두) 로 그룹 자릿수를 고른다
groups :: String -> Maybe [Int]
groups ds = case (length ds, "02" `isPrefixOf` ds) of
(11, _) -> Just [3, 4, 4]
(10, True) -> Just [2, 4, 4]
(10, False) -> Just [3, 3, 4]
(9, True) -> Just [2, 3, 4]
_ -> Nothing -- 'Invalid phone number'
format :: String -> Maybe String
format raw = intercalate "-" . splitPlaces' ds <$> groups ds
where ds = filter isDigit raw
-- replace 는 매치된 곳만 바꾸고 나머지는 뒤에 남긴다 → sum groups == length ds 여야 한다