{"categories":["Haskell"],"published":"2010-07-22 05:32:33","author_name":"sirocco","blog_title":"sirocco \u306e\u66f8\u3044\u3066\u3082\u3059\u3050\u306b\u5fd8\u308c\u308b\u30e1\u30e2","url":"https://sirocco.hatenadiary.org/entry/20100722/1279830753","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fsirocco.hatenadiary.org%2Fentry%2F20100722%2F1279830753\" title=\"newtype \u3092\u4f5c\u3063\u3066\u307f\u308b - sirocco \u306e\u66f8\u3044\u3066\u3082\u3059\u3050\u306b\u5fd8\u308c\u308b\u30e1\u30e2\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","title":"newtype \u3092\u4f5c\u3063\u3066\u307f\u308b","provider_url":"https://hatena.blog","version":"1.0","image_url":null,"description":"\u3084\u3055\u3057\u3044 Haskell \u5165\u9580 (\u30d0\u30fc\u30b8\u30e7\u30f3 98 ) 6 \u518d\u3073\u3001\u578b\u306b\u3064\u3044\u3066 6.1 Newtype \u5ba3\u8a00 \u3092\u53c2\u8003\u306b newtype \u3092\u4f5c\u3063\u3066\u307f\u307e\u3059\u3002 newtype Age = Age Integer deriving (Eq, Read, Show) toAge :: Integer -> Age toAge x | x < 0 = error \"Can't create negative age!\" | otherwise = Age x fromAge :: Age -> Integer fromAge (Age i) = i instance Num Age where fromIn\u2026","author_url":"https://blog.hatena.ne.jp/sirocco/","type":"rich","height":"190","width":"100%","blog_url":"https://sirocco.hatenadiary.org/","provider_name":"Hatena Blog"}