
{"id":668,"date":"2010-11-06T22:53:19","date_gmt":"2010-11-07T02:53:19","guid":{"rendered":"http:\/\/www.ikriv.com\/blog\/?p=668"},"modified":"2010-11-06T22:53:19","modified_gmt":"2010-11-07T02:53:19","slug":"f-parametrized-types","status":"publish","type":"post","link":"https:\/\/ikriv.com\/blog\/?p=668","title":{"rendered":"F#: Parametrized Types"},"content":{"rendered":"<p>Learned something new today. It turns out in current incarnation of F# you can have &#8220;parametrized types&#8221;. Although it sounds like another flavor of templates, it is nothing like it. These are the types with &#8220;units of measure&#8221; attached. You can have weight value of type float<kg> divided by volume of type float<m^3> to achieve density of type &lt;kg\/m^3&gt;. E.g. 2.5&lt;kg&gt;\/5.0&lt;m^3&gt; yields 0.5&lt;kg\/m^3&gt;.<\/p>\n<p>The measures exist only for F# compiler. They are &#8220;erased&#8221; when creating the IL code, so they can&#8217;t be queried at runtime. I am not sure yet how generic this can be made and what other applications besides physics it might have.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learned something new today. It turns out in current incarnation of F# you can have &#8220;parametrized types&#8221;. Although it sounds like another flavor of templates, it is nothing like it. <a href=\"https:\/\/ikriv.com\/blog\/?p=668\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[10],"tags":[],"class_list":["entry","author-ikriv","post-668","post","type-post","status-publish","format-standard","category-fsharp"],"_links":{"self":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/668","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=668"}],"version-history":[{"count":0,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/668\/revisions"}],"wp:attachment":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}