èªåã§å®ç¾©ãããã¼ã¿ã®ä¸ã«ã¯ã足ãç®ããããªããããªãã¼ã¿ãããããã¨ãã°ãéä¿¡ã¨åä¿¡ã®ã«ã¦ã³ã¿ã¼ãå®ç¾©ããã¨ãããã data Metrics = Metrics { rx :: Int , ts :: Int } deriving (Eq, Show) ããã¯ä»¥ä¸ã®ããã«è¶³ãç®ã§ããã¨å¬ããã ããã > Metrics 1 2 + Metrics 3 4 Metrics {rx = 4, ts = 6} ããããã㯠Num ã®ã¤ã³ã¹ã¿ã³ã¹ã«ãã¹ãã§ã¯ãªãããã®ãã¼ã¿åã«æãç®ã¯å®ç¾©ã§ããªãããã ããã¨ãã£ã¦ãaddMetrics ã¿ãããªé¢æ°ãå®ç¾©ããã®ã¯ãã£ãæªãã > Metrics 1 2 `addMetrics` Metrics 3 4 Metrics {rx = 4, ts = 6} ãã®ããã«æ¼ç®åãä¸åã ã欲ããã¨æã£ãããããã¯å¤å Monoid ã ã import
{{#tags}}- {{label}}
{{/tags}}