Haskellã®recordã使ã£ã¦ããã¨ããããäºãããããã data Test = T { a :: Int, b :: String } updateA :: Test -> (Int -> Int) -> Test updateA t f = t { a = f (a t) } Teståã®ãã¼ã¿ã®aãfé¢æ°ã使ã£ã¦æ´æ°ãããã ä¾ãã°ã»ããStateã«ã¯modifyé¢æ°ããããããããªãã§ããã modify :: (s -> s) -> State s () ã¨ããæãã§ãsãæ´æ°ããé¢æ°ãå¼æ°ã«ã¨ããå®éã¨ã¯ã¡ãã£ã¨éããã©ãã§ãã¬ã³ã¼ãã§ãããããæãã®äºããããã å ·ä½çã«ã¯ããã update name f rec = rec { name = f (name rec) } recordã®ãã£ã¼ã«ãã©ãã«ã¾ã§å¼æ°ã¨ãã¦æ¸¡ãããããã§ããããã³ã³ãã¤ã«ã§ããªããã§ããã©
{{#tags}}- {{label}}
{{/tags}}