{"id":337404,"date":"2022-08-23T09:00:20","date_gmt":"2022-08-23T09:00:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=337404"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=337404","title":{"rendered":"<span>Discriminated Unions \u0432 C#<\/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<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442. \u0421\u0440\u0435\u0434\u0438 \u043c\u043d\u043e\u0433\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0439, \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0432 F#, \u043c\u0435\u043d\u044f \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u043b\u0438 Discriminated Unions. \u042f \u0437\u0430\u0434\u0430\u043b\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c, \u043a\u0430\u043a \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432 C#, \u0432\u0435\u0434\u044c \u0432 \u043d\u0435\u043c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 (\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f) \u0442\u0438\u043f\u043e\u0432 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439, \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u0439\u0442\u0438 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0445 \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>Discriminated Unions &#8212; \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043e\u0431\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445).<\/p>\n<p>\u0418\u0434\u0435\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c <strong>\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435<\/strong> \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0432\u044b\u0431\u043e\u0440\u0430, \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 <strong>\u0441\u0432\u043e\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong>, \u043d\u0438\u043a\u0430\u043a <strong>\u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445<\/strong> \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438, \u043d\u043e \u0432\u0441\u0435 \u0432\u0430\u0440\u0438\u043d\u0430\u043d\u0442\u044b <strong>\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b<\/strong> \u043e\u0431\u0449\u0438\u043c \u043f\u043e\u0434\u0442\u0438\u043f\u043e\u043c. <\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 Discriminated Unions \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043c\u044b\u0441\u043b\u044c<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>&#171;\u042d\u0442\u0430\u043b\u043e\u043d\u043e\u043c&#187; \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 F#<\/p>\n<pre><code class=\"fsharp\">type Worker =     | Developer of KnownLanguages: string seq     | Manager of MaintainedProjectsCount: int     | Tester of UnitTestsPerHour: double<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 C#<\/p>\n<pre><code class=\"cs\">public abstract record RecordWorker {        private RecordWorker(){ }     public record Developer(IEnumerable&lt;string> KnownLanguages): RecordWorker { }      public record Manager(int MaintainedProjectsCount) : RecordWorker;      public record Tester(double UnitTestsPerHour) : RecordWorker; }<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442, \u043f\u043e\u0434 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438:<\/p>\n<ol>\n<li>\n<p>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 &#8212; \u0432\u0441\u0435 \u0432\u0430\u0440\u0430\u043d\u0442\u044b \u0432\u044b\u0431\u043e\u0440\u0430 &#8212; \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u0432\u043e\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 &#8212; \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u0449\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c\/\u043f\u043e\u0434\u0442\u0438\u043f\u043e\u043c &#8212; \u0432\u0441\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b record, \u0442.\u043a. \u043e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u0434\u0430 \u0438 \u043f\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044e \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0438 \u043d\u0430 Discriminated Unions.<\/p>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430 F#, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0430\u044f \u043d\u0430\u0448 \u0442\u0438\u043f:<\/p>\n<pre><code class=\"fsharp\">let getWorkerInfo (worker: Worker) =     match worker with     | Developer knownLanguages ->      $\"Known languages: %s{String.Join(',', knownLanguages)}\"     | Manager maintainedProjectsCount ->      $\"Currently maintained projects count %i{maintainedProjectsCount}\"     | Tester unitTestsPerHour ->      $\"My testing speed is %f{unitTestsPerHour} unit tests per hour\"<\/code><\/pre>\n<p>\u041d\u0430 C# \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">string GetWorkerInfo(Worker w) {     return worker switch            {                Worker.Developer(var knownLanguages) =>                    $\"Known languages {string.Join(',', knownLanguages)}\",                                Worker.Manager(var maintainedProjectsCount) =>                    $\"Currently maintained projects count {maintainedProjectsCount}\",                                Worker.Tester(var unitTestsPerHour) =>                    $\"My testing speed is {unitTestsPerHour} unit tests per hour\",                                _ =>                    throw new ArgumentOutOfRangeException(nameof(worker), worker, null)            }; }<\/code><\/pre>\n<p>\u041d\u0430\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 IDE (Rider \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0440\u0443\u0433\u0430\u0435\u0442\u0441\u044f \u0438\u0437-\u0437\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e):<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2b6\/94b\/885\/2b694b88589eb2f0cd2f7e8815fb4fae.png\" width=\"963\" height=\"423\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2b6\/94b\/885\/2b694b88589eb2f0cd2f7e8815fb4fae.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439<\/h2>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">\n<\/td>\n<td>\n<p align=\"left\">C#<\/p>\n<\/td>\n<td>\n<p align=\"left\">F#<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432<\/p>\n<\/td>\n<td>\n<p align=\"left\">IDE (\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b &#8212; \u043a\u043b\u0430\u0441\u0441\u044b-\u043f\u043e\u043b\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u0435\u0433\u0438 (Enum)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b<\/p>\n<\/td>\n<td>\n<p align=\"left\">IEquatable&lt;Worker><\/p>\n<\/td>\n<td>\n<p align=\"left\">IEquatable&lt;Worker><\/p>\n<p align=\"left\">IStructuralEquatable <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 <\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 (New*)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u0432 \u0440\u0430\u0439\u043d\u0442\u0430\u0439\u043c\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 (Is*)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">Get\/Set<\/p>\n<\/td>\n<td>\n<p align=\"left\">Get-only<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">==, !=, Equals<\/p>\n<\/td>\n<td>\n<p align=\"left\">Equals<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 Discriminated Unions<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u0430, \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u044b\u0431\u043e\u0440\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u043c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0435\u0442, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 DU \u0432\u044b\u0448\u0435 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0432\u044b\u0431\u043e\u0440\u0430 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 IL<\/p>\n<\/td>\n<td colspan=\"2\">\n<p align=\"center\">\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0435\u0433\u043e \u0432\u0430\u0440\u0430\u043d\u0442\u0430\u043c\u0438-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430<\/p>\n<\/td>\n<td colspan=\"2\">\n<p align=\"center\">\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0441 backing field<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0414\u0435\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0435\u0439<\/p>\n<\/td>\n<td colspan=\"2\">\n<p align=\"center\">\u0415\u0441\u0442\u044c<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b Is* \u0434\u043b\u044f Discriminated Unions \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>\u041c\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 record`\u0430\u0445 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u0442\u043e\u0442, \u0447\u0442\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c F# (\u0412 \u0447\u0435\u043c-\u0442\u043e \u0434\u0430\u0436\u0435 \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u0438\u0442). <\/p>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043d\u043e\u0433\u043e: \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445, \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u0445, partial \u043a\u043b\u0430\u0441\u0441\u044b. <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u0432\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0438\u0445 \u043f\u043e\u043b\u0435\u0439 &#8212;  \u0432 Discriminated Unions \u043e\u0431\u0449\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 Tag \u0438 Is* \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0442\u0438\u043f\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043a\u0430\u043a Discriminated Unions \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e, \u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 <a href=\"https:\/\/habr.com\/ru\/post\/470275\/\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0441\u0442<\/a> \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0435. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b \u0432\u0430\u0436\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/post\/684104\/\"> https:\/\/habr.com\/ru\/post\/684104\/<\/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<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442. \u0421\u0440\u0435\u0434\u0438 \u043c\u043d\u043e\u0433\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0439, \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0432 F#, \u043c\u0435\u043d\u044f \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u043b\u0438 Discriminated Unions. \u042f \u0437\u0430\u0434\u0430\u043b\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c, \u043a\u0430\u043a \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432 C#, \u0432\u0435\u0434\u044c \u0432 \u043d\u0435\u043c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 (\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f) \u0442\u0438\u043f\u043e\u0432 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439, \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u0439\u0442\u0438 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0445 \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>Discriminated Unions &#8212; \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043e\u0431\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445).<\/p>\n<p>\u0418\u0434\u0435\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c <strong>\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435<\/strong> \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0432\u044b\u0431\u043e\u0440\u0430, \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 <strong>\u0441\u0432\u043e\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong>, \u043d\u0438\u043a\u0430\u043a <strong>\u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445<\/strong> \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438, \u043d\u043e \u0432\u0441\u0435 \u0432\u0430\u0440\u0438\u043d\u0430\u043d\u0442\u044b <strong>\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b<\/strong> \u043e\u0431\u0449\u0438\u043c \u043f\u043e\u0434\u0442\u0438\u043f\u043e\u043c. <\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 Discriminated Unions \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043c\u044b\u0441\u043b\u044c<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>&#171;\u042d\u0442\u0430\u043b\u043e\u043d\u043e\u043c&#187; \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 F#<\/p>\n<pre><code class=\"fsharp\">type Worker =     | Developer of KnownLanguages: string seq     | Manager of MaintainedProjectsCount: int     | Tester of UnitTestsPerHour: double<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 C#<\/p>\n<pre><code class=\"cs\">public abstract record RecordWorker {        private RecordWorker(){ }     public record Developer(IEnumerable&lt;string> KnownLanguages): RecordWorker { }      public record Manager(int MaintainedProjectsCount) : RecordWorker;      public record Tester(double UnitTestsPerHour) : RecordWorker; }<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442, \u043f\u043e\u0434 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438:<\/p>\n<ol>\n<li>\n<p>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 &#8212; \u0432\u0441\u0435 \u0432\u0430\u0440\u0430\u043d\u0442\u044b \u0432\u044b\u0431\u043e\u0440\u0430 &#8212; \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u0432\u043e\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 &#8212; \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u0449\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c\/\u043f\u043e\u0434\u0442\u0438\u043f\u043e\u043c &#8212; \u0432\u0441\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b record, \u0442.\u043a. \u043e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u0434\u0430 \u0438 \u043f\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044e \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0438 \u043d\u0430 Discriminated Unions.<\/p>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430 F#, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0430\u044f \u043d\u0430\u0448 \u0442\u0438\u043f:<\/p>\n<pre><code class=\"fsharp\">let getWorkerInfo (worker: Worker) =     match worker with     | Developer knownLanguages ->      $\"Known languages: %s{String.Join(',', knownLanguages)}\"     | Manager maintainedProjectsCount ->      $\"Currently maintained projects count %i{maintainedProjectsCount}\"     | Tester unitTestsPerHour ->      $\"My testing speed is %f{unitTestsPerHour} unit tests per hour\"<\/code><\/pre>\n<p>\u041d\u0430 C# \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">string GetWorkerInfo(Worker w) {     return worker switch            {                Worker.Developer(var knownLanguages) =>                    $\"Known languages {string.Join(',', knownLanguages)}\",                                Worker.Manager(var maintainedProjectsCount) =>                    $\"Currently maintained projects count {maintainedProjectsCount}\",                                Worker.Tester(var unitTestsPerHour) =>                    $\"My testing speed is {unitTestsPerHour} unit tests per hour\",                                _ =>                    throw new ArgumentOutOfRangeException(nameof(worker), worker, null)            }; }<\/code><\/pre>\n<p>\u041d\u0430\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 IDE (Rider \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0440\u0443\u0433\u0430\u0435\u0442\u0441\u044f \u0438\u0437-\u0437\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e):<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439<\/h2>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">\n<\/td>\n<td>\n<p align=\"left\">C#<\/p>\n<\/td>\n<td>\n<p align=\"left\">F#<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432<\/p>\n<\/td>\n<td>\n<p align=\"left\">IDE (\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b &#8212; \u043a\u043b\u0430\u0441\u0441\u044b-\u043f\u043e\u043b\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u0435\u0433\u0438 (Enum)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b<\/p>\n<\/td>\n<td>\n<p align=\"left\">IEquatable&lt;Worker><\/p>\n<\/td>\n<td>\n<p align=\"left\">IEquatable&lt;Worker><\/p>\n<p align=\"left\">IStructuralEquatable <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 <\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 (New*)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u0432 \u0440\u0430\u0439\u043d\u0442\u0430\u0439\u043c\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0422\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 (Is*)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">Get\/Set<\/p>\n<\/td>\n<td>\n<p align=\"left\">Get-only<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">==, !=, Equals<\/p>\n<\/td>\n<td>\n<p align=\"left\">Equals<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 Discriminated Unions<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u0430, \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u044b\u0431\u043e\u0440\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u043c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0435\u0442, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 DU \u0432\u044b\u0448\u0435 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0432\u044b\u0431\u043e\u0440\u0430 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 IL<\/p>\n<\/td>\n<td colspan=\"2\">\n<p align=\"center\">\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0435\u0433\u043e \u0432\u0430\u0440\u0430\u043d\u0442\u0430\u043c\u0438-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430<\/p>\n<\/td>\n<td colspan=\"2\">\n<p align=\"center\">\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0441 backing field<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0414\u0435\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0435\u0439<\/p>\n<\/td>\n<td colspan=\"2\">\n<p align=\"center\">\u0415\u0441\u0442\u044c<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b Is* \u0434\u043b\u044f Discriminated Unions \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>\u041c\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 record`\u0430\u0445 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u0442\u043e\u0442, \u0447\u0442\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c F# (\u0412 \u0447\u0435\u043c-\u0442\u043e \u0434\u0430\u0436\u0435 \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u0438\u0442). <\/p>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043d\u043e\u0433\u043e: \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445, \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u0445, partial \u043a\u043b\u0430\u0441\u0441\u044b. <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u0432\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0438\u0445 \u043f\u043e\u043b\u0435\u0439 &#8212;  \u0432 Discriminated Unions \u043e\u0431\u0449\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 Tag \u0438 Is* \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0442\u0438\u043f\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043a\u0430\u043a Discriminated Unions \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e, \u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 <a href=\"https:\/\/habr.com\/ru\/post\/470275\/\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0441\u0442<\/a> \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0435. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b \u0432\u0430\u0436\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/post\/684104\/\"> https:\/\/habr.com\/ru\/post\/684104\/<\/a><br \/><\/br><\/br><\/p>\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-337404","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/337404","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=337404"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/337404\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=337404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=337404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=337404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}