{"blog_title":"yunomu\u306e\u30d6\u30ed\u30b0","version":"1.0","height":"190","type":"rich","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fyunomu.hatenablog.jp%2Fentry%2F2013%2F03%2F01%2F065843\" title=\"record update - yunomu\u306e\u30d6\u30ed\u30b0\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","categories":["Haskell"],"provider_name":"Hatena Blog","author_url":"https://blog.hatena.ne.jp/yunomu/","author_name":"yunomu","blog_url":"https://yunomu.hatenablog.jp/","published":"2013-03-01 06:58:43","title":"record update","width":"100%","image_url":null,"url":"https://yunomu.hatenablog.jp/entry/2013/03/01/065843","provider_url":"https://hatena.blog","description":"Haskell\u306erecord\u3092\u4f7f\u3063\u3066\u3044\u308b\u3068\u3053\u3046\u3044\u3046\u4e8b\u3092\u3088\u304f\u3084\u308b\u3002 data Test = T { a :: Int, b :: String } updateA :: Test -> (Int -> Int) -> Test updateA t f = t { a = f (a t) } Test\u578b\u306e\u30c7\u30fc\u30bf\u306ea\u3092f\u95a2\u6570\u3092\u4f7f\u3063\u3066\u66f4\u65b0\u3057\u305f\u3044\u3002\u4f8b\u3048\u3070\u307b\u3089\u3001State\u306b\u306fmodify\u95a2\u6570\u304c\u3042\u308b\u308f\u3051\u3058\u3083\u306a\u3044\u3067\u3059\u304b\u3002 modify :: (s -> s) -> State s () \u3068\u3044\u3046\u611f\u3058\u3067\u3001s\u3092\u66f4\u65b0\u3059\u308b\u95a2\u6570\u3092\u5f15\u6570\u306b\u3068\u308b\u3002\u5b9f\u969b\u3068\u306f\u3061\u3087\u3063\u3068\u9055\u3046\u3051\u3069\u3002\u3067\u3082\u30ec\u30b3\u30fc\u30c9\u3067\u3082\u3053\u3046\u3044\u3046\u611f\u3058\u306e\u4e8b\u304c\u3057\u305f\u3044\u3002\u5177\u4f53\u7684\u306b\u306f\u3053\u2026"}