{"id":410289,"date":"2024-06-29T21:17:45","date_gmt":"2024-06-29T21:17:45","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=410289"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=410289","title":{"rendered":"<span>Yet another \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 fp-ts. \u0427\u0430\u0441\u0442\u044c 2. \u041c\u043e\u043d\u043e\u0438\u0434\u044b \u0438 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u044b<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/65a\/ac4\/0c8\/65aac40c80662028672ff99e60794c83.jpg\" width=\"960\" height=\"1040\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/65a\/ac4\/0c8\/65aac40c80662028672ff99e60794c83.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/domclick\/articles\/725164\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u0446\u0438\u043a\u043b\u0430 \u0441\u0442\u0430\u0442\u0435\u0439 \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u043e \u0442\u043e\u043c, \u0437\u0430\u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0443\u0436\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0441\u0443\u0434\u0438\u043b\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0442\u0438\u043f\u043e\u0432 \u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445: <strong><em>Eq<\/em><\/strong> (\u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c) \u0438 <strong><em>Ord<\/em><\/strong> (\u0441\u0440\u0430\u0432\u043d\u0438\u043c\u043e\u0441\u0442\u044c).<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u0445\u043e\u0447\u0443 \u043f\u0440\u043e\u043b\u0438\u0442\u044c \u0441\u0432\u0435\u0442 \u043d\u0430 \u0434\u0432\u0430 \u043d\u0430\u0432\u043e\u0434\u044f\u0449\u0438\u0445 \u0436\u0443\u0442\u044c \u043d\u0430 \u043d\u0435\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u0441\u043b\u043e\u0432\u0430: <em>\u043c\u043e\u043d\u043e\u0438\u0434\u044b<\/em> \u0438 <em>\u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u044b<\/em>. \u042d\u0442\u043e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u0440\u043e\u0434\u043e\u043c \u0438\u0437 \u043e\u0431\u0449\u0435\u0439 \u0430\u043b\u0433\u0435\u0431\u0440\u044b. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u0441\u0451 \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u0441\u0442\u0440\u0430\u0448\u043d\u043e. \u0415\u0441\u043b\u0438 \u0441\u043e\u0432\u0441\u0435\u043c \u0443\u043f\u0440\u043e\u0449\u0430\u0442\u044c, \u0442\u043e \u043e\u0431\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u0430 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430. \u042f \u043f\u043e\u043c\u043e\u0433\u0443 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0438 \u0437\u0430\u0447\u0435\u043c \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/h3>\n<p>\u041f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432 \u043f\u0440\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441: \u00ab\u0410 \u043c\u043d\u0435 \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e?\u00bb \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0443\u0436\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u043b, \u0447\u0442\u043e, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043d\u0435\u0442. \u041f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u0449\u0438\u043d\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>fp-ts<\/code> \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0441 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u0438 \u0447\u0430\u0441\u0442\u043e \u043c\u0435\u043d\u044f\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438. \u041d\u043e \u0438\u0440\u043e\u043d\u0438\u044f \u0432 \u0442\u043e\u043c \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a (\u0434\u0430\u0436\u0435 junior) \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u0438\u043c\u0435\u0435\u0442 \u0434\u0435\u043b\u043e \u0441 \u043c\u043e\u043d\u043e\u0438\u0434\u0430\u043c\u0438 \u0438 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438, \u0441\u0430\u043c \u0442\u043e\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u044f. \u0414\u0430-\u0434\u0430, \u043c\u044b \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0447\u0442\u043e-\u0442\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c, \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0438 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0430\u0435\u043c.<\/p>\n<h3>\u0410\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f<\/h3>\n<p>\u041f\u043e\u0434 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0443\u044e \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0443\u044e \u043e\u0434\u0438\u043d \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u041f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043c\u0430\u0441\u0441\u0430. \u0414\u0432\u0430 \u0447\u0438\u0441\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u043e\u0436\u0438\u0442\u044c, \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c, \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u043b\u0438 \u0432\u043e\u0437\u0432\u0435\u0441\u0442\u0438 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c, \u0432\u0437\u044f\u0442\u044c \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044e \u0434\u0440\u0443\u0433\u043e\u0433\u043e. \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0434\u043e\u043b\u0433\u043e.<\/p>\n<p>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 <code>a<\/code>, <code>b<\/code> \u0438 <code>c<\/code> \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0435\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"( a\\ \\circ \\ b) \\ \\circ \\ c\\ =\\ ( a\\ \\circ \\ c) \\ \\circ \\ b\" alt=\"( a\\ \\circ \\ b) \\ \\circ \\ c\\ =\\ ( a\\ \\circ \\ c) \\ \\circ \\ b\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ad5\/8eb\/93d\/ad58eb93dfa097b7b4d54912a755f5d1.svg\" width=\"234\" height=\"22\"\/><\/p>\n<p>\u0414\u0430-\u0434\u0430, \u043e\u0442 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 (\u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0435\u0439) \u0441\u0443\u043c\u043c\u0430 (\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435) \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0432\u0441\u0435 \u043c\u044b \u0438\u043c\u0435\u043b\u0438 \u0434\u0435\u043b\u043e \u0441 <s>\u0412\u0430\u0441\u0438\u043d\u044b\u043c\u0438 \u0438 \u041f\u0435\u0442\u0438\u043d\u044b\u043c\u0438 \u0430\u043f\u0435\u043b\u044c\u0441\u0438\u043d\u0430\u043c\u0438<\/s> \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0435\u0449\u0451 \u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0448\u043a\u043e\u043b\u0435. \u0422\u043e\u043b\u044c\u043a\u043e \u043a\u0440\u0443\u0436\u043e\u0447\u0435\u043a \u0432 \u0444\u043e\u0440\u043c\u0443\u043b\u0435 \u0432\u044b\u0448\u0435 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0441\u0443\u043c\u043c\u0443 \u0438\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0437\u0434\u0435\u0441\u044c \u0441\u0442\u043e\u0438\u0442 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0448\u0438\u0440\u0435. \u042d\u0442\u043e \u043b\u044e\u0431\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0442 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<h3>\u041a\u043b\u0430\u0441\u0441 \u0442\u0438\u043f\u043e\u0432 Semigroup \u2014 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430<\/h3>\n<p>\u0424\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430 \u2014 \u044d\u0442\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043d\u0430 \u043d\u0451\u043c \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439. \u042d\u0442\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0432 <code>fp-ts<\/code> \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u0435\u0439 (<strong><em>concat<\/em><\/strong>). \u0412\u0430\u0436\u043d\u043e \u0437\u0430\u043e\u0441\u0442\u0440\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u0430\u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b a \u0438 b, \u0442\u0430\u043a \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u00ab\u0432\u044b\u043b\u0435\u0437\u0430\u0442\u044c\u00bb \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 (\u0442\u043e \u0435\u0441\u0442\u044c \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u043e\u0434\u0438\u043d \u0442\u0438\u043f). \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u0434. \u041a\u043b\u0430\u0441\u0441 \u0442\u0438\u043f\u043e\u0432 <strong><em>Semigroup<\/em><\/strong> \u0432 <code>fp-ts<\/code> \u2014 \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430:<\/p>\n<pre><code class=\"typescript\">interface Semigroup&lt;A> {   readonly concat: (x: A, y: A) => A \/\/ \u044d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0439 }<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u0445\u043e\u0434\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c:<\/p>\n<pre><code class=\"typescript\">import { Semigroup } from \"fp-ts\/Semigroup\";  \/** \u041f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430 \u0434\u043b\u044f \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b *\/ const semigroupProduct: Semigroup&lt;number> = {   concat: (x, y) => x * y, };  \/** \u041f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430 \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b *\/ const semigroupSum: Semigroup&lt;number> = {   concat: (x, y) => x + y, };  \/** \u041f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u043a *\/ const semigroupString: Semigroup&lt;string> = {   concat: (x, y) => x + y, };  semigroupProduct.concat(3, 2); \/\/ 6 semigroupSum.concat(3, 2); \/\/ 5 semigroupString.concat(\"Hello \", \"world!\"); \/\/ \"Hello world!\"<\/code><\/pre>\n<p>\u041d\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 <code>fp-ts<\/code> \u0435\u0441\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<pre><code class=\"typescript\">import { SemigroupSum, SemigroupProduct } from \"fp-ts\/number\"; import { Semigroup as SemigroupString } from \"fp-ts\/string\";  SemigroupProduct.concat(3, 2); \/\/ 6 SemigroupSum.concat(3, 2); \/\/ 5 SemigroupString.concat('Hello ', 'world!'); \/\/ \"Hello world!\"<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u0430\u043a \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u0441\u043b\u0438\u044f\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a, \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 HTML-\u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438. \u041f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0434\u0438\u043d. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u0430 \u0438 \u0441\u0442\u0440\u043e\u043a\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u0430 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442 \u043f\u043e\u043b\u044c\u0437\u0443 \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e.<\/p>\n<p>\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0414\u043e\u043c\u043a\u043b\u0438\u043a \u0438 \u0438\u043f\u043e\u0442\u0435\u0447\u043d\u043e\u0433\u043e \u0431\u0438\u0437\u043d\u0435\u0441\u0430, \u043d\u043e \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u0441 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043b\u0438\u0446\u0430\u043c\u0438 \u2014 \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043c\u044b \u0442\u0440\u0435\u0431\u0443\u0435\u043c \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0441\u0435\u0431\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u043f\u043e\u0434\u0430\u0447\u0435 \u0438\u043f\u043e\u0442\u0435\u0447\u043d\u043e\u0439 \u0437\u0430\u044f\u0432\u043a\u0438 (\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0434\u043b\u044f \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u044f \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b \u043c\u0435\u0447\u0442\u044b) \u043a\u043b\u0438\u0435\u043d\u0442 \u0432\u0432\u043e\u0434\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0411\u0438\u0437\u043d\u0435\u0441-\u0437\u0430\u0434\u0430\u0447\u0430: \u00ab\u0441\u043a\u043b\u0435\u0438\u0442\u044c\u00bb \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p>\u041d\u0430 \u00ab\u0433\u043e\u043b\u043e\u043c\u00bb <code>Typescript<\/code> \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"typescript\">\/\/ \u041f\u0440\u043e\u0444\u0430\u0439\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f type TProfile = {   \/\/ \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u044f\u0432\u043e\u043a \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043e\u0434\u043e\u0431\u0440\u0435\u043d\u0438\u044f   realEstateObjects: TRealEstate[];   name: string;   isVerificated: boolean;   registeredAt: number | null;   lastUpdatedAt: number; };  const initialProfile: TProfile = {   realEstateObjects: [],   name: \"\u0412\u0430\u043d\u044f \u0418\u0432\u0430\u043d\u043e\u0432\",   isVerificated: false,   registeredAt: new Date(\"2023-07-01T08:03:53.438Z\").getTime(),   lastUpdatedAt: new Date(\"2023-07-01T08:03:53.438Z\").getTime() };  const loanApplicationProfile: TProfile = {   realEstateObjects: [     {       id: 24242,       area: 55.56,       address: \"\u0421\u0430\u043d\u043a\u0442-\u041f\u0435\u0442\u0435\u0440\u0431\u0443\u0440\u0433, \u0443\u043b. \u041a\u0440\u0430\u0441\u0438\u0432\u044b\u0445 \u043c\u043e\u043b\u0434\u0430\u0432\u0441\u043a\u0438\u0445 \u043f\u0430\u0440\u0442\u0438\u0437\u0430\u043d, \u0434.47, \u043a\u0432. 35\"     }   ],   name: \"\u0418\u0432\u0430\u043d\u043e\u0432 \u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447\",   isVerificated: true,   registeredAt: null,   lastUpdatedAt: new Date(\"2023-07-02T11:17:03.438Z\").getTime() };  \/\/ \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f const mergeProfiles = (   firstProfile: TProfile,   secondProfile: TProfile ): TProfile => {   return {     ...firstProfile,     realEstateObjects: [       ...firstProfile.realEstateObjects,       ...secondProfile.realEstateObjects     ],     isVerificated: firstProfile.isVerificated || secondProfile.isVerificated,     name: (() => {       if (firstProfile.name.length >= secondProfile.name.length) {         return firstProfile.name;       }        return secondProfile.name;     })(),     registeredAt: (() => {       \/\/ \u0443\u0445\u043e\u0434\u0438\u043c \u043e\u0442 \"\u0433\u0440\u0430\u0431\u043b\u0435\u0439\" 0 || null => null       if (firstProfile.registeredAt === 0 &amp;&amp; secondProfile.registeredAt)         return firstProfile.registeredAt;        return firstProfile.registeredAt || secondProfile.registeredAt;     })(),     lastUpdatedAt: (() => {       if (firstProfile.lastUpdatedAt >= secondProfile.lastUpdatedAt)         return firstProfile.lastUpdatedAt;        return secondProfile.lastUpdatedAt;     })()   }; };  const mergedProfile = mergeProfiles(initialProfile, loanApplicationProfile);<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u0438 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0442\u0438\u043f\u043e\u0432 <strong><em>Semigroup<\/em><\/strong> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>fp-ts<\/code> \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u0438\u0437\u044f\u0449\u043d\u0435\u0435 \u0438 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u0435\u0435:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"typescript\">import { Semigroup, max, struct } from \"fp-ts\/Semigroup\"; import { Ord as OrdNumber } from \"fp-ts\/number\"; import { contramap } from \"fp-ts\/Ord\"; import { SemigroupAny } from \"fp-ts\/boolean\"; import { getMonoid } from \"fp-ts\/Array\";  \/\/ \u041e\u0431\u044a\u0435\u043a\u0442 \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u0438 type TRealEstate = {   id: number;   area: number;   address: string; };  \/\/ \u041f\u0440\u043e\u0444\u0430\u0439\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f type TProfile = {   \/\/ \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u044f\u0432\u043e\u043a \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043e\u0434\u043e\u0431\u0440\u0435\u043d\u0438\u044f   realEstateObjects: TRealEstate[];   name: string;   isVerificated: boolean;   registeredAt: number | null;   lastUpdatedAt: number; };  const initialProfile: TProfile = {   realEstateObjects: [],   name: \"\u0412\u0430\u043d\u044f \u0418\u0432\u0430\u043d\u043e\u0432\",   isVerificated: false,   registeredAt: new Date(\"2023-07-01T08:03:53.438Z\").getTime(),   lastUpdatedAt: new Date(\"2023-07-01T08:03:53.438Z\").getTime() };  const loanApplicationProfile: TProfile = {   realEstateObjects: [     {       id: 24242,       area: 55.56,       address: \"\u0421\u0430\u043d\u043a\u0442-\u041f\u0435\u0442\u0435\u0440\u0431\u0443\u0440\u0433, \u0443\u043b. \u041a\u0440\u0430\u0441\u0438\u0432\u044b\u0445 \u043c\u043e\u043b\u0434\u0430\u0432\u0441\u043a\u0438\u0445 \u043f\u0430\u0440\u0442\u0438\u0437\u0430\u043d, \u0434.47, \u043a\u0432. 35\"     }   ],   name: \"\u0418\u0432\u0430\u043d\u043e\u0432 \u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447\",   isVerificated: true,   registeredAt: null,   lastUpdatedAt: new Date(\"2023-07-02T11:17:03.438Z\").getTime() };  \/\/ \u0418\u043d\u043e\u0433\u0434\u0430 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e const EmptyDateSemigroup: Semigroup&lt;number | null> = {   concat: (x, y) => {     if (x === 0 &amp;&amp; y === null) return x;      return x || y;   } };  \/\/ \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0432\u0435\u0441\u044c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443 const MergeProfilesSemigroup: Semigroup&lt;TProfile> = struct({   realEstateObjects: getMonoid&lt;TRealEstate>(), \/\/ \u043f\u0440\u043e \u043c\u043e\u043d\u043e\u0438\u0434\u044b \u043d\u0438\u0436\u0435   isVerificated: SemigroupAny, \/\/ boolean || boolean   name: max(contramap((s: string) => s.length)(OrdNumber)), \/\/ \u0441\u0430\u043c\u044b\u0439 \u0434\u043b\u0438\u043d\u043d\u044b\u0439 name   lastUpdatedAt: max(OrdNumber), \/\/ \u0441\u0430\u043c\u0430\u044f \u043f\u043e\u0437\u0434\u043d\u044f\u044f \u0434\u0430\u0442\u0430   registeredAt: EmptyDateSemigroup \/\/ \u043c\u0435\u0436\u0434\u0443 \"null\" \u0438 \"\u043d\u0435 null\" \u0432\u044b\u0431\u0435\u0440\u0435\u043c \"\u043d\u0435 null\"  });  const mergedProfile = MergeProfilesSemigroup.concat(   initialProfile,   loanApplicationProfile );<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0433\u0438\u0431\u043a\u043e \u043f\u043e\u0434\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f (\u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0442\u0438\u043f\u043e\u0432 <strong><em>Semigroup<\/em><\/strong> \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044f). <strong><em>Semigroup<\/em><\/strong> \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u00ab\u0441\u0435\u0440\u0435\u0431\u0440\u044f\u043d\u043e\u0439 \u043f\u0443\u043b\u0435\u0439\u00bb, \u0438 \u043d\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0438 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u043c. \u042d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u00ab\u043d\u0435\u0443\u0434\u043e\u0431\u043d\u044b\u0439\u00bb \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u044b \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u0430\u043a \u00ab\u0443\u0434\u043e\u0431\u043d\u044b\u0439\u00bb, \u043d\u043e \u044d\u0442\u043e \u043f\u043e\u0432\u043b\u0435\u0447\u0451\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<h3>\u041a\u043b\u0430\u0441\u0441 \u0442\u0438\u043f\u043e\u0432 Monoid \u2014 \u043c\u043e\u043d\u043e\u0438\u0434<\/h3>\n<p>\u041c\u043e\u043d\u043e\u0438\u0434 \u2014 \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430 \u0441 \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u0445\u043e\u0442\u044c \u0438 \u043a\u0440\u0430\u0442\u043a\u043e\u0435, \u043d\u043e \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 \u0434\u043b\u044f \u043d\u0435\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e. \u0412\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>x<\/code>, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"a\\ \\circ \\ x\\ =\\ a\" alt=\"a\\ \\circ \\ x\\ =\\ a\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2bf\/8fd\/f7c\/2bf8fdf7c00b4cb9eaf078e1f84e4872.svg\" width=\"96\" height=\"12\"\/><\/p>\n<p>\u0414\u0430-\u0434\u0430, \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430 \u0438\u0437 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0448\u043a\u043e\u043b\u044b \u0437\u0434\u0435\u0441\u044c \u0442\u043e\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0415\u0441\u043b\u0438 \u0443 \u041f\u0435\u0442\u0438 \u0431\u044b\u043b\u043e 5 \u0430\u043f\u0435\u043b\u044c\u0441\u0438\u043d\u043e\u0432, \u0430 \u0412\u0430\u0441\u044f \u0434\u0430\u043b \u041f\u0435\u0442\u0435 0 \u0430\u043f\u0435\u043b\u044c\u0441\u0438\u043d\u043e\u0432, \u0442\u043e \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0441\u0447\u0451\u0442\u0435 \u0443 \u041f\u0435\u0442\u0438 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u0430\u043a \u0436\u0435 5 \u0430\u043f\u0435\u043b\u044c\u0441\u0438\u043d\u043e\u0432. \u0414\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u2014 \u044d\u0442\u043e 0, \u0434\u043b\u044f \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u2014 1. \u0414\u043b\u044f \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u043a \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u2014 \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430.<\/p>\n<p>\u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 <code>fp-ts<\/code> \u043a\u043b\u0430\u0441\u0441 \u0442\u0438\u043f\u043e\u0432 <strong><em>Monoid<\/em><\/strong> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<pre><code class=\"typescript\">interface Monoid&lt;A> {   readonly concat: (x: A, y: A) => A;   readonly empty: A; }  \/\/ \u0438\u043b\u0438 \u043a\u0430\u043a \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442 Semigroup: interface Monoid&lt;A> extends Semigroup&lt;A> {   readonly empty: A }<\/code><\/pre>\n<p>\u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u043c\u043e\u043d\u043e\u0438\u0434\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<pre><code class=\"typescript\">import { Monoid } from \"fp-ts\/Monoid\";  const monoidString: Monoid&lt;string> = {   concat: (x, y) => x + y,   empty: '', }  const monoidSum: Monoid&lt;number> = {   concat: (x, y) => x + y,   empty: 0, }  const monoidMultiply: Monoid&lt;number> = {   concat: (x, y) => x * y,   empty: 1, }  monoidString.concat(\"Hello, \", \"world!\"); \/\/ => \"Hello, world!\" monoidSum.concat(8, 2); \/\/ => 10 monoidMultiply.concat(8, 2); \/\/ => 16<\/code><\/pre>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <code>fp-ts<\/code> \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u044d\u0442\u0438 \u0438 \u043c\u043d\u043e\u0433\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"typescript\">import { MonoidSum, MonoidProduct } from 'fp-ts\/number' import { Monoid as MonoidString }  from 'fp-ts\/string';  MonoidString.concat(\"Hello, \", \"world!\"); \/\/ => \"Hello, world!\" MonoidSum.concat(8, 2); \/\/ => 10 MonoidProduct.concat(8, 2); \/\/ => 16<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043c\u043e\u043d\u043e\u0438\u0434\u043e\u0432 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f: \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u043a (\u0441\u0442\u0440\u043e\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e \u0442\u0430\u043a \u0438 \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e), \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u0435\u043b, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 (\u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u0438) \u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0449\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0422\u043e \u0435\u0441\u0442\u044c, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f (\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e <em>\u0434\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/em>), \u043c\u043e\u043d\u043e\u0438\u0434\u044b \u0434\u0430\u044e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c <em>\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/em> <em>\u0432 \u043e\u0434\u0438\u043d<\/em>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/e3b\/550\/59f\/e3b55059f39ac3b29a886e6cc514ddb7.jpeg\" width=\"888\" height=\"500\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e3b\/550\/59f\/e3b55059f39ac3b29a886e6cc514ddb7.jpeg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u041e\u0434\u043d\u043e \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0414\u043e\u043c\u043a\u043b\u0438\u043a \u2014 \u044d\u0442\u043e \u0432\u044b\u0434\u0430\u0447\u0430 \u0438\u043f\u043e\u0442\u0435\u0447\u043d\u044b\u0445 \u043a\u0440\u0435\u0434\u0438\u0442\u043e\u0432 \u0432 \u043d\u043e\u0432\u043e\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043d\u043e\u0432\u043e\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043d\u0435 \u0432\u043e\u0437\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u00ab\u043e\u0434\u0438\u043d \u0434\u043e\u043c \u043f\u043e\u0441\u0440\u0435\u0434\u0438 \u043f\u043e\u043b\u044f\u00bb, \u044d\u0442\u043e \u0446\u0435\u043b\u044b\u0439 \u0436\u0438\u043b\u043e\u0439 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043c\u043e\u0432. \u0417\u0430\u0434\u0430\u0447\u0430: \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0432\u0441\u0435\u0433\u043e \u0436\u0438\u043b\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u0430. \u041d\u0430\u0448\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<ul>\n<li>\n<p><strong>\u0416\u0438\u043b\u0430\u044f \u043f\u043b\u043e\u0449\u0430\u0434\u044c<\/strong>. \u0421\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0436\u0438\u043b\u043e\u0439 \u043f\u043b\u043e\u0449\u0430\u0434\u0438 \u0432\u0441\u0435\u0445 \u0434\u043e\u043c\u043e\u0432, \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 \u0416\u041a.<\/p>\n<\/li>\n<li>\n<p><strong>\u041a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u043b\u043e\u0449\u0430\u0434\u044c<\/strong>. \u0417\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u0436\u0435 \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u043b\u043e\u0449\u0430\u0434\u044c \u0432\u0441\u0435\u0445 \u043d\u043e\u0432\u043e\u0441\u0442\u0440\u043e\u0435\u043a \u0432 \u0416\u041a.<\/p>\n<\/li>\n<li>\n<p><strong>\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u044d\u0442\u0430\u0436\u043d\u043e\u0441\u0442\u044c<\/strong> \u2014 \u044d\u0442\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0430\u043c\u043e\u0433\u043e \u0432\u044b\u0441\u043e\u043a\u043e\u0433\u043e \u0434\u043e\u043c\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0430\u043b\u0438\u0447\u0438\u0435 \u043a\u043e\u0444\u0435\u0439\u043d\u0438 \u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u043e\u0433\u043e \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430.<\/strong> \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u0432 \u043e\u0434\u043d\u043e\u043c \u0434\u043e\u043c\u0435 \u0416\u041a \u0435\u0441\u0442\u044c \u043a\u043e\u0444\u0435\u0439\u043d\u044f \u0438\u043b\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0439 \u043c\u0430\u0433\u0430\u0437\u0438\u043d, \u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u043d \u0435\u0441\u0442\u044c \u0432\u043e \u0432\u0441\u0451\u043c \u0416\u041a.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c <code>Typescript<\/code>, \u0442\u043e \u043a\u043e\u0434 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u043e, \u0430 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0435 \u0431\u0438\u0437\u043d\u0435\u0441-\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"typescript\">type THouse = {   livingArea: number;   businessArea: number;   apartmentsCount: number;   commertialCount: number;   floors: number;   hasStore: boolean;   hasCoffeeHouse: boolean; };  const house1: THouse = {   livingArea: 1240,   businessArea: 400,   apartmentsCount: 250,   commertialCount: 7,   floors: 16,   hasCoffeeHouse: true,   hasStore: false };  const house2: THouse = {   livingArea: 1750,   businessArea: 440,   apartmentsCount: 350,   commertialCount: 10,   floors: 25,   hasCoffeeHouse: false,   hasStore: false };  const house3: THouse = {   livingArea: 940,   businessArea: 440,   apartmentsCount: 180,   commertialCount: 10,   floors: 10,   hasCoffeeHouse: false,   hasStore: true };  \/\/ \u043b\u043e\u0433\u0438\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a const mergeHouses = (houses: THouse[]): THouse =>   houses.reduce(     (acc, house) => {       return {         ...acc, \/\/ \u0442\u0443\u0442 \u043b\u0435\u0433\u043a\u043e \u043e\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c\u0441\u044f \u0438 \u0441\u043b\u043e\u0436\u0438\u0442\u044c \"\u0436\u0438\u043b\u0443\u044e \u043f\u043b\u043e\u0449\u0430\u0434\u044c\" \u0438 \"\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0432\u0430\u0440\u0442\u0438\u0440\"       \/\/ ts \u044d\u0442\u043e \u043d\u0435 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u0438\u0442         livingArea: acc.livingArea + house.livingArea,         businessArea: acc.businessArea + house.businessArea,         apartmentsCount: acc.apartmentsCount + house.apartmentsCount,         commertialCount: acc.commertialCount + house.commertialCount,         hasCoffeeHouse: acc.hasCoffeeHouse || house.hasCoffeeHouse,         hasStore: acc.hasStore || house.hasStore,         floors: (() => {           if (house.floors > acc.floors) return house.floors;            return acc.floors;         })()       };     },     {       livingArea: 0,       businessArea: 0,       apartmentsCount: 0,       commertialCount: 0,       hasCoffeeHouse: false,       hasStore: false,       floors: 0     }   );  const result = mergeHouses([house1, house2, house3]);<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0442\u0438\u043f\u043e\u0432 <strong><em>Monoid<\/em><\/strong> \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>fp-ts<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0439:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"typescript\">import { struct, max, concatAll } from \"fp-ts\/Monoid\"; import { MonoidSum, Bounded as BoundedNum } from \"fp-ts\/number\"; import { MonoidAny } from \"fp-ts\/boolean\";  type THouse = {   livingArea: number;   businessArea: number;   apartmentsCount: number;   commertialCount: number;   floors: number;   hasStore: boolean;   hasCoffeeHouse: boolean; };  const house1: THouse = {   livingArea: 1240,   businessArea: 400,   apartmentsCount: 250,   commertialCount: 7,   floors: 16,   hasCoffeeHouse: true,   hasStore: false };  const house2: THouse = {   livingArea: 1750,   businessArea: 440,   apartmentsCount: 350,   commertialCount: 10,   floors: 25,   hasCoffeeHouse: false,   hasStore: false };  const house3: THouse = {   livingArea: 940,   businessArea: 440,   apartmentsCount: 180,   commertialCount: 10,   floors: 10,   hasCoffeeHouse: false,   hasStore: true };  \/\/ \u0412\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0437\u0434\u0435\u0441\u044c const M = struct&lt;THouse>({   livingArea: MonoidSum, \/\/ \u043f\u043b\u043e\u0449\u0430\u0434\u0438 \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f   businessArea: MonoidSum, \/\/ \u043f\u043b\u043e\u0449\u0430\u0434\u0438 \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f   apartmentsCount: MonoidSum, \/\/ \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0432\u0430\u0440\u0442\u0438\u0440 \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f   commertialCount: MonoidSum, \/\/ \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0439 \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f   hasCoffeeHouse: MonoidAny, \/\/ \u0435\u0441\u043b\u0438 \u0433\u0434\u0435-\u0442\u043e true, \u0442\u043e \u0432\u0441\u0451 true   hasStore: MonoidAny, \/\/ \u0435\u0441\u043b\u0438 \u0433\u0434\u0435-\u0442\u043e true, \u0442\u043e \u0432\u0441\u0451 true   floors: max(BoundedNum) \/\/ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 });  \/\/ \u042d\u0442\u043e\u0442 \u0445\u044d\u043b\u043f\u0435\u0440 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0432\u0441\u0435 \u043c\u043e\u043d\u043e\u0438\u0434\u044b const result = concatAll(M)([house1, house2, house3]);<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438, \u043a\u043b\u0430\u0441\u0441 \u0442\u0438\u043f\u043e\u0432 <strong><em>Monoid<\/em><\/strong> \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b \u043d\u0430\u043c \u0443\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043b\u043e\u0433\u0438\u043a\u0443 \u0432\u0441\u0435\u0433\u043e \u0432 9 \u0441\u0442\u0440\u043e\u043a \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u041d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0442\u0440\u0443\u0434\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a \u0434\u043e\u043c\u043e\u0432 \u0432 \u0436\u0438\u043b\u043e\u043c \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u0435 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430. \u041a\u043b\u0430\u0441\u0441 \u0442\u0438\u043f\u043e\u0432 <strong><em>Monoid<\/em><\/strong> \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442 \u0447\u0430\u0449\u0435, \u0447\u0435\u043c <strong><em>Semigroup<\/em><\/strong>, \u0432\u0435\u0434\u044c, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u043e \u0432\u044b\u0448\u0435, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0434\u0430\u0436\u0435 \u0441\u0430\u043c \u0442\u043e\u0433\u043e \u043d\u0435 \u043e\u0441\u043e\u0437\u043d\u0430\u0432\u0430\u044f, \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u0438\u043c\u0435\u0435\u0442 \u0434\u0435\u043b\u043e \u0441 \u043c\u043e\u043d\u043e\u0438\u0434\u0430\u043c\u0438.<\/p>\n<h3>\u0412\u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0432\u044b\u0448\u0435 \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043b\u0438\u043a\u0431\u0435\u0437 \u043f\u043e \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430\u043c (\u043a\u043b\u0430\u0441\u0441 \u0442\u0438\u043f\u043e\u0432 <strong><em>Semigroup<\/em><\/strong>) \u0438 \u043c\u043e\u043d\u043e\u0438\u0434\u0430\u043c (\u043a\u043b\u0430\u0441\u0441 \u0442\u0438\u043f\u043e\u0432 <strong><em>Monoid<\/em><\/strong>) \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>fp-ts<\/code>. \u0411\u044b\u043b\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u043e\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0442\u0438\u043f\u043e\u0432. \u041e\u0447\u0435\u043d\u044c \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043c\u043e\u0433\u043b\u0430 \u0432\u0430\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u043d\u0430 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u044d\u0442\u0438 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u044d\u0442\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0441\u0442\u0430\u0442\u0435\u0439 \u043c\u044b \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0438 \u0435\u0449\u0451 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/domclick\/articles\/725164\/\">\u042d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u043e\u0441\u0442\u044c (\u043a\u043b\u0430\u0441\u0441\u044b \u0442\u0438\u043f\u043e\u0432 Eq \u0438 Ord)<\/a>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435, \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u044b \u0438 \u043c\u043e\u043d\u0430\u0434\u044b (\u043a\u043b\u0430\u0441\u0441\u044b \u0442\u0438\u043f\u043e\u0432 <strong><em>Option<\/em><\/strong> \u0438 <strong><em>Either<\/em><\/strong>).<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0431\u043e\u0442\u0443 \u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 <code>fp-ts<\/code> (\u043a\u043b\u0430\u0441\u0441\u044b \u0442\u0438\u043f\u043e\u0432 <strong><em>Task<\/em><\/strong> \u0438 <strong><em>TaskEither<\/em><\/strong>).<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043e\u0441\u0442\u0430\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u0441\u0432\u044f\u0437\u0438.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/745922\/\"> https:\/\/habr.com\/ru\/articles\/745922\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/domclick\/articles\/725164\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u0446\u0438\u043a\u043b\u0430 \u0441\u0442\u0430\u0442\u0435\u0439 \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u043e \u0442\u043e\u043c, \u0437\u0430\u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0443\u0436\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0441\u0443\u0434\u0438\u043b\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0442\u0438\u043f\u043e\u0432 \u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445: <strong><em>Eq<\/em><\/strong> (\u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c) \u0438 <strong><em>Ord<\/em><\/strong> (\u0441\u0440\u0430\u0432\u043d\u0438\u043c\u043e\u0441\u0442\u044c).<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u0445\u043e\u0447\u0443 \u043f\u0440\u043e\u043b\u0438\u0442\u044c \u0441\u0432\u0435\u0442 \u043d\u0430 \u0434\u0432\u0430 \u043d\u0430\u0432\u043e\u0434\u044f\u0449\u0438\u0445 \u0436\u0443\u0442\u044c \u043d\u0430 \u043d\u0435\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u0441\u043b\u043e\u0432\u0430: <em>\u043c\u043e\u043d\u043e\u0438\u0434\u044b<\/em> \u0438 <em>\u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u044b<\/em>. \u042d\u0442\u043e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u0440\u043e\u0434\u043e\u043c \u0438\u0437 \u043e\u0431\u0449\u0435\u0439 \u0430\u043b\u0433\u0435\u0431\u0440\u044b. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u0441\u0451 \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u0441\u0442\u0440\u0430\u0448\u043d\u043e. \u0415\u0441\u043b\u0438 \u0441\u043e\u0432\u0441\u0435\u043c \u0443\u043f\u0440\u043e\u0449\u0430\u0442\u044c, \u0442\u043e \u043e\u0431\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u0430 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430. \u042f \u043f\u043e\u043c\u043e\u0433\u0443 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0438 \u0437\u0430\u0447\u0435\u043c \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/h3>\n<p>\u041f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432 \u043f\u0440\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441: \u00ab\u0410 \u043c\u043d\u0435 \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e?\u00bb \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0443\u0436\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u043b, \u0447\u0442\u043e, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043d\u0435\u0442. \u041f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u0449\u0438\u043d\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>fp-ts<\/code> \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0441 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u0438 \u0447\u0430\u0441\u0442\u043e \u043c\u0435\u043d\u044f\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438. \u041d\u043e \u0438\u0440\u043e\u043d\u0438\u044f \u0432 \u0442\u043e\u043c \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a (\u0434\u0430\u0436\u0435 junior) \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u0438\u043c\u0435\u0435\u0442 \u0434\u0435\u043b\u043e \u0441 \u043c\u043e\u043d\u043e\u0438\u0434\u0430\u043c\u0438 \u0438 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438, \u0441\u0430\u043c \u0442\u043e\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u044f. \u0414\u0430-\u0434\u0430, \u043c\u044b \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0447\u0442\u043e-\u0442\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c, \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0438 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0430\u0435\u043c.<\/p>\n<h3>\u0410\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f<\/h3>\n<p>\u041f\u043e\u0434 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0443\u044e \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0443\u044e \u043e\u0434\u0438\u043d \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u041f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043c\u0430\u0441\u0441\u0430. \u0414\u0432\u0430 \u0447\u0438\u0441\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u043e\u0436\u0438\u0442\u044c, \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c, \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u043b\u0438 \u0432\u043e\u0437\u0432\u0435\u0441\u0442\u0438 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c, \u0432\u0437\u044f\u0442\u044c \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044e \u0434\u0440\u0443\u0433\u043e\u0433\u043e. \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0434\u043e\u043b\u0433\u043e.<\/p>\n<p>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 <code>a<\/code>, <code>b<\/code> \u0438 <code>c<\/code> \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0435\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435:<\/p>\n<p>\u0414\u0430-\u0434\u0430, \u043e\u0442 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 (\u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0435\u0439) \u0441\u0443\u043c\u043c\u0430 (\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435) \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0432\u0441\u0435 \u043c\u044b \u0438\u043c\u0435\u043b\u0438 \u0434\u0435\u043b\u043e \u0441 <s>\u0412\u0430\u0441\u0438\u043d\u044b\u043c\u0438 \u0438 \u041f\u0435\u0442\u0438\u043d\u044b\u043c\u0438 \u0430\u043f\u0435\u043b\u044c\u0441\u0438\u043d\u0430\u043c\u0438<\/s> \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0435\u0449\u0451 \u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0448\u043a\u043e\u043b\u0435. \u0422\u043e\u043b\u044c\u043a\u043e \u043a\u0440\u0443\u0436\u043e\u0447\u0435\u043a \u0432 \u0444\u043e\u0440\u043c\u0443\u043b\u0435 \u0432\u044b\u0448\u0435 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0441\u0443\u043c\u043c\u0443 \u0438\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0437\u0434\u0435\u0441\u044c \u0441\u0442\u043e\u0438\u0442 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0448\u0438\u0440\u0435. \u042d\u0442\u043e \u043b\u044e\u0431\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0442 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<h3>\u041a\u043b\u0430\u0441\u0441 \u0442\u0438\u043f\u043e\u0432 Semigroup \u2014 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430<\/h3>\n<p>\u0424\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430 \u2014 \u044d\u0442\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043d\u0430 \u043d\u0451\u043c \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439. \u042d\u0442\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0432 <code>fp-ts<\/code> \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u0435\u0439 (<strong><em>concat<\/em><\/strong>). \u0412\u0430\u0436\u043d\u043e \u0437\u0430\u043e\u0441\u0442\u0440\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u0430\u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b a \u0438 b, \u0442\u0430\u043a \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u00ab\u0432\u044b\u043b\u0435\u0437\u0430\u0442\u044c\u00bb \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 (\u0442\u043e \u0435\u0441\u0442\u044c \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u043e\u0434\u0438\u043d \u0442\u0438\u043f). \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u0434. \u041a\u043b\u0430\u0441\u0441 \u0442\u0438\u043f\u043e\u0432 <strong><em>Semigroup<\/em><\/strong> \u0432 <code>fp-ts<\/code> \u2014 \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430:<\/p>\n<pre><code class=\"typescript\">interface Semigroup&lt;A> {   readonly concat: (x: A, y: A) => A \/\/ \u044d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0439 }<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u0445\u043e\u0434\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c:<\/p>\n<pre><code class=\"typescript\">import { Semigroup } from \"fp-ts\/Semigroup\";  \/** \u041f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430 \u0434\u043b\u044f \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b *\/ const semigroupProduct: Semigroup&lt;number> = {   concat: (x, y) => x * y, };  \/** \u041f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430 \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b *\/ const semigroupSum: Semigroup&lt;number> = {   concat: (x, y) => x + y, };  \/** \u041f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u043a *\/ const semigroupString: Semigroup&lt;string> = {   concat: (x, y) => x + y, };  semigroupProduct.concat(3, 2); \/\/ 6 semigroupSum.concat(3, 2); \/\/ 5 semigroupString.concat(\"Hello \", \"world!\"); \/\/ \"Hello world!\"<\/code><\/pre>\n<p>\u041d\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 <code>fp-ts<\/code> \u0435\u0441\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<pre><code class=\"typescript\">import { SemigroupSum, SemigroupProduct } from \"fp-ts\/number\"; import { Semigroup as SemigroupString } from \"fp-ts\/string\";  SemigroupProduct.concat(3, 2); \/\/ 6 SemigroupSum.concat(3, 2); \/\/ 5 SemigroupString.concat('Hello ', 'world!'); \/\/ \"Hello world!\"<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u0430\u043a \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u0441\u043b\u0438\u044f\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a, \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 HTML-\u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438. \u041f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0434\u0438\u043d. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u0430 \u0438 \u0441\u0442\u0440\u043e\u043a\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u0430 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442 \u043f\u043e\u043b\u044c\u0437\u0443 \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e.<\/p>\n<p>\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0414\u043e\u043c\u043a\u043b\u0438\u043a \u0438 \u0438\u043f\u043e\u0442\u0435\u0447\u043d\u043e\u0433\u043e \u0431\u0438\u0437\u043d\u0435\u0441\u0430, \u043d\u043e \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u0441 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043b\u0438\u0446\u0430\u043c\u0438 \u2014 \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043c\u044b \u0442\u0440\u0435\u0431\u0443\u0435\u043c \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0441\u0435\u0431\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u043f\u043e\u0434\u0430\u0447\u0435 \u0438\u043f\u043e\u0442\u0435\u0447\u043d\u043e\u0439 \u0437\u0430\u044f\u0432\u043a\u0438 (\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0434\u043b\u044f \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u044f \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b \u043c\u0435\u0447\u0442\u044b) \u043a\u043b\u0438\u0435\u043d\u0442 \u0432\u0432\u043e\u0434\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0411\u0438\u0437\u043d\u0435\u0441-\u0437\u0430\u0434\u0430\u0447\u0430: \u00ab\u0441\u043a\u043b\u0435\u0438\u0442\u044c\u00bb \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p>\u041d\u0430 \u00ab\u0433\u043e\u043b\u043e\u043c\u00bb <code>Typescript<\/code> \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"typescript\">\/\/ \u041f\u0440\u043e\u0444\u0430\u0439\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f type TProfile = {   \/\/ \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u044f\u0432\u043e\u043a \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043e\u0434\u043e\u0431\u0440\u0435\u043d\u0438\u044f   realEstateObjects: TRealEstate[];   name: string;   isVerificated: boolean;   registeredAt: number | null;   lastUpdatedAt: number; };  const initialProfile: TProfile = {   realEstateObjects: [],   name: \"\u0412\u0430\u043d\u044f \u0418\u0432\u0430\u043d\u043e\u0432\",   isVerificated: false,   registeredAt: new Date(\"2023-07-01T08:03:53.438Z\").getTime(),   lastUpdatedAt: new Date(\"2023-07-01T08:03:53.438Z\").getTime() };  const loanApplicationProfile: TProfile = {   realEstateObjects: [     {       id: 24242,       area: 55.56,       address: \"\u0421\u0430\u043d\u043a\u0442-\u041f\u0435\u0442\u0435\u0440\u0431\u0443\u0440\u0433, \u0443\u043b. \u041a\u0440\u0430\u0441\u0438\u0432\u044b\u0445 \u043c\u043e\u043b\u0434\u0430\u0432\u0441\u043a\u0438\u0445 \u043f\u0430\u0440\u0442\u0438\u0437\u0430\u043d, \u0434.47, \u043a\u0432. 35\"     }   ],   name: \"\u0418\u0432\u0430\u043d\u043e\u0432 \u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447\",   isVerificated: true,   registeredAt: null,   lastUpdatedAt: new Date(\"2023-07-02T11:17:03.438Z\").getTime() };  \/\/ \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f const mergeProfiles = (   firstProfile: TProfile,   secondProfile: TProfile ): TProfile => {   return {     ...firstProfile,     realEstateObjects: [       ...firstProfile.realEstateObjects,       ...secondProfile.realEstateObjects     ],     isVerificated: firstProfile.isVerificated || secondProfile.isVerificated,     name: (() => {       if (firstProfile.name.length >= secondProfile.name.length) {         return firstProfile.name;       }        return secondProfile.name;     })(),     registeredAt: (() => {       \/\/ \u0443\u0445\u043e\u0434\u0438\u043c \u043e\u0442 \"\u0433\u0440\u0430\u0431\u043b\u0435\u0439\" 0 || null => null       if (firstProfile.registeredAt === 0 &amp;&amp; secondProfile.registeredAt)         return firstProfile.registeredAt;        return firstProfile.registeredAt || secondProfile.registeredAt;     })(),     lastUpdatedAt: (() => {       if (firstProfile.lastUpdatedAt >= secondProfile.lastUpdatedAt)         return firstProfile.lastUpdatedAt;        return secondProfile.lastUpdatedAt;     })()   }; };  const mergedProfile = mergeProfiles(initialProfile, loanApplicationProfile);<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u0438 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0442\u0438\u043f\u043e\u0432 <strong><em>Semigroup<\/em><\/strong> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>fp-ts<\/code> \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u0438\u0437\u044f\u0449\u043d\u0435\u0435 \u0438 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u0435\u0435:<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"typescript\">import { Semigroup, max, struct } from \"fp-ts\/Semigroup\"; import { Ord as OrdNumber } from \"fp-ts\/number\"; import { contramap } from \"fp-ts\/Ord\"; import { SemigroupAny } from \"fp-ts\/boolean\"; import { getMonoid } from \"fp-ts\/Array\";  \/\/ \u041e\u0431\u044a\u0435\u043a\u0442 \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u0438 type TRealEstate = {   id: number;   area: number;   address: string; };  \/\/ \u041f\u0440\u043e\u0444\u0430\u0439\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f type TProfile = {   \/\/ \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u044f\u0432\u043e\u043a \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043e\u0434\u043e\u0431\u0440\u0435\u043d\u0438\u044f   realEstateObjects: TRealEstate[];   name: string;   isVerificated: boolean;   registeredAt: number | null;   lastUpdatedAt: number; };  const initialProfile: TProfile = {   realEstateObjects: [],   name: \"\u0412\u0430\u043d\u044f \u0418\u0432\u0430\u043d\u043e\u0432\",   isVerificated: false,   registeredAt: new Date(\"2023-07-01T08:03:53.438Z\").getTime(),   lastUpdatedAt: new Date(\"2023-07-01T08:03:53.438Z\").getTime() };  const loanApplicationProfile: TProfile = {   realEstateObjects: [     {       id: 24242,       area: 55.56,       address: \"\u0421\u0430\u043d\u043a\u0442-\u041f\u0435\u0442\u0435\u0440\u0431\u0443\u0440\u0433, \u0443\u043b. \u041a\u0440\u0430\u0441\u0438\u0432\u044b\u0445 \u043c\u043e\u043b\u0434\u0430\u0432\u0441\u043a\u0438\u0445 \u043f\u0430\u0440\u0442\u0438\u0437\u0430\u043d, \u0434.47, \u043a\u0432. 35\"     }   ],   name: \"\u0418\u0432\u0430\u043d\u043e\u0432 \u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447\",   isVerificated: true,   registeredAt: null,   lastUpdatedAt: new Date(\"2023-07-02T11:17:03.438Z\").getTime() };  \/\/ \u0418\u043d\u043e\u0433\u0434\u0430 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e const EmptyDateSemigroup: Semigroup&lt;number | null> = {   concat: (x, y) => {     if (x === 0 &amp;&amp; y === null) return x;      return x || y;   } };  \/\/ \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0432\u0435\u0441\u044c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443 const MergeProfilesSemigroup: Semigroup&lt;TProfile> = struct({   realEstateObjects: getMonoid&lt;TRealEstate>(), \/\/ \u043f\u0440\u043e \u043c\u043e\u043d\u043e\u0438\u0434\u044b \u043d\u0438\u0436\u0435   isVerificated: SemigroupAny, \/\/ boolean || boolean   name: max(contramap((s: string) => s.length)(OrdNumber)), \/\/ \u0441\u0430\u043c\u044b\u0439 \u0434\u043b\u0438\u043d\u043d\u044b\u0439 name   lastUpdatedAt: max(OrdNumber), \/\/ \u0441\u0430\u043c\u0430\u044f \u043f\u043e\u0437\u0434\u043d\u044f\u044f \u0434\u0430\u0442\u0430   registeredAt: EmptyDateSemigroup \/\/ \u043c\u0435\u0436\u0434\u0443 \"null\" \u0438 \"\u043d\u0435 null\" \u0432\u044b\u0431\u0435\u0440\u0435\u043c \"\u043d\u0435 null\"  });  const mergedProfile = MergeProfilesSemigroup.concat(   initialProfile,   loanApplicationProfile );<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0433\u0438\u0431\u043a\u043e \u043f\u043e\u0434\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f (\u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0442\u0438\u043f\u043e\u0432 <strong><em>Semigroup<\/em><\/strong> \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044f). <strong><em>Semigroup<\/em><\/strong> \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u00ab\u0441\u0435\u0440\u0435\u0431\u0440\u044f\u043d\u043e\u0439 \u043f\u0443\u043b\u0435\u0439\u00bb, \u0438 \u043d\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0438 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u043c. \u042d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u00ab\u043d\u0435\u0443\u0434\u043e\u0431\u043d\u044b\u0439\u00bb \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u044b \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u0430\u043a \u00ab\u0443\u0434\u043e\u0431\u043d\u044b\u0439\u00bb, \u043d\u043e \u044d\u0442\u043e \u043f\u043e\u0432\u043b\u0435\u0447\u0451\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<h3>\u041a\u043b\u0430\u0441\u0441 \u0442\u0438\u043f\u043e\u0432 Monoid \u2014 \u043c\u043e\u043d\u043e\u0438\u0434<\/h3>\n<p>\u041c\u043e\u043d\u043e\u0438\u0434 \u2014 \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0433\u0440\u0443\u043f\u043f\u0430 \u0441 \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u0445\u043e\u0442\u044c \u0438 \u043a\u0440\u0430\u0442\u043a\u043e\u0435, \u043d\u043e \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 \u0434\u043b\u044f \u043d\u0435\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e. \u0412\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>x<\/code>, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c:<\/p>\n<p>\u0414\u0430-\u0434\u0430, \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430 \u0438\u0437 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0448\u043a\u043e\u043b\u044b \u0437\u0434\u0435\u0441\u044c \u0442\u043e\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0415\u0441\u043b\u0438 \u0443 \u041f\u0435\u0442\u0438 \u0431\u044b\u043b\u043e 5 \u0430\u043f\u0435\u043b\u044c\u0441\u0438\u043d\u043e\u0432, \u0430 \u0412\u0430\u0441\u044f \u0434\u0430\u043b \u041f\u0435\u0442\u0435 0 \u0430\u043f\u0435\u043b\u044c\u0441\u0438\u043d\u043e\u0432, \u0442\u043e \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0441\u0447\u0451\u0442\u0435 \u0443 \u041f\u0435\u0442\u0438 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u0430\u043a \u0436\u0435 5 \u0430\u043f\u0435\u043b\u044c\u0441\u0438\u043d\u043e\u0432. \u0414\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u2014 \u044d\u0442\u043e 0, \u0434\u043b\u044f \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u2014 1. \u0414\u043b\u044f \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u043a \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u2014 \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430.<\/p>\n<p>\u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 <code>fp-ts<\/code> \u043a\u043b\u0430\u0441\u0441 \u0442\u0438\u043f\u043e\u0432 <strong><em>Monoid<\/em><\/strong> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<pre><code class=\"typescript\">interface Monoid&lt;A> {   readonly concat: (x: A, y: A) => A;   readonly empty: A; }  \/\/ \u0438\u043b\u0438 \u043a\u0430\u043a \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442 Semigroup: interface Monoid&lt;A> extends Semigroup&lt;A> {   readonly empty: A }<\/code><\/pre>\n<p>\u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u043c\u043e\u043d\u043e\u0438\u0434\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<pre><code class=\"typescript\">import { Monoid } from \"fp-ts\/Monoid\";  const monoidString: Monoid&lt;string> = {   concat: (x, y) => x + y,   empty: '', }  const monoidSum: Monoid&lt;number> = {   concat: (x, y) => x + y,   empty: 0, }  const<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-410289","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/410289","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=410289"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/410289\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=410289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=410289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=410289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}