{"id":84,"date":"2014-02-21T21:12:04","date_gmt":"2014-02-21T12:12:04","guid":{"rendered":"http:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/?p=84"},"modified":"2014-02-21T23:31:50","modified_gmt":"2014-02-21T14:31:50","slug":"haskell%e3%81%ae%e9%96%a2%e6%95%b0%e5%be%93%e5%b1%9e%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/?p=84","title":{"rendered":"Haskell\u306e\u95a2\u6570\u5f93\u5c5e\u306b\u3064\u3044\u3066"},"content":{"rendered":"<p>\u3084\u3063\u3068\u5206\u304b\u3063\u305f\u6c17\u304c\u3059\u308b\u306e\u3067\u307e\u3068\u3081\u308b\u3002<\/p>\n<h2>\u95a2\u6570\u5f93\u5c5e\u6027\u3068\u306f\u4f55\u304b\uff1f<\/h2>\n<p>Parsec\u30e9\u30a4\u30d6\u30e9\u30ea\u306a\u3069\u3092\u898b\u3066\u3044\u308b\u3068\u578b\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5ba3\u8a00\u306b\u95a2\u6570\u5f93\u5c5e\u6027\u304c\u8a18\u8ff0\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u3042\u308b\u3002<\/p>\n<pre lang=\"haskell\">\ninstance Moge a b c | a b -> c\n<\/pre>\n<p>\u3068\u3044\u3063\u305f\u611f\u3058\u3060\u3002|\u304b\u3089\u53f3\u5074\u304c\u5f93\u5c5e\u6027\u3092\u8868\u3057\u3066\u3044\u308b\u3002<br \/>\na, b\u306e\u578b\u304b\u3089c\u306e\u578b\u3092\u5c0e\u51fa\u3057\u3066\u826f\u3044\u3068\u3044\u3046\u3053\u3068\u3092\u30b3\u30f3\u30d1\u30a4\u30e9\u306b\u793a\u3059\u305f\u3081\u306e\u3082\u306e\u3067\u3042\u308b\u3002<\/p>\n<h2>\u4f55\u6545\u3053\u308c\u304c\u5fc5\u8981\u306a\u306e\u304b\uff1f<\/h2>\n<p>\u307e\u305a\u3001\u3053\u308c\u304c\u5fc5\u8981\u306b\u306a\u308b\u5c40\u9762\u3068\u3057\u3066\u306f\u3001\u578b\u30af\u30e9\u30b9\u306b\u8907\u6570\u306e\u578b\u5909\u6570\u3092\u6307\u5b9a\u3067\u304d\u308b\u5834\u5408\u306b\u306e\u307f\u5fc5\u8981\u3067\u3042\u308b\u3002<\/p>\n<pre lang=\"haskell\">\n{-# LANGUAGE MultiParamTypeClasses #-}\nclass Mult a b c \n<\/pre>\n<p>\u3068\u306a\u3063\u3066\u3044\u308b\u3088\u3046\u306a\u5834\u5408\u3067\u3042\u308b\u3002<\/p>\n<p>\u3053\u306e\u6642<\/p>\n<pre lang=\"haskell\">\ninstance Multi Matrix Matrix Matrix\n<\/pre>\n<p>\u3068\u3057\u3066<\/p>\n<pre lang=\"haskell\">\nm1 :: Matrix\nm2 :: Matrix\n(m1 * m2) \n<\/pre>\n<p>\u3068\u3044\u3046\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u52d5\u304b\u3059\u3068\u3001m1 * m2 \u3067\u30a8\u30e9\u30fc\u3068\u306a\u308b\u3002<br \/>\n\u3053\u308c\u306f\u3001\u30b3\u30f3\u30d1\u30a4\u30e9\u304cinstance\u3092\u5b9a\u3081\u308b\u3068\u304d\u306bMulti a b c \u306e\u3046\u3061\u3001a = Matrix, b = Matrix\u3068\u3044\u3046\u3068\u3053\u308d\u307e\u3067\u6c7a\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002\u3057\u304b\u3057\u3001c\u3092\u6c7a\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u305f\u3081\u3001c \u306e\u578b\u3092\u6c7a\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u3002<\/p>\n<p>instance\u306e\u3046\u3061a, b\u304cMatrix\u3068\u306a\u3063\u3066\u3044\u308binstance\u306f\u4e00\u3064\u3057\u304b\u306a\u3044\u304b\u3089\u63a8\u8ad6\u3057\u3066\u307b\u3057\u3044\u3068\u8003\u3048\u305f\u304c\u3001\u5b9f\u969b\u305d\u308c\u306f\u8aa4\u308a\u3067\u3042\u308b\u3002<\/p>\n<p>\u30b3\u30f3\u30d1\u30a4\u30e9\u306e\u7acb\u5834\u3067\u306f\u4ed6\u306e\u7ffb\u8a33\u5358\u4f4d\u306ba = Matrix, b = Matrix, c = Int\u306a\u308binstance\u304c\u306a\u3044\u3053\u3068\u3092\u4fdd\u8a3c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u304b\u3089\u3067\u3042\u308b\u3002<\/p>\n<pre lang=\"haskell\">\n(m1 * m2) :: Matrix\n<\/pre>\n<p>\u3068\u30b3\u30f3\u30d1\u30a4\u30e9\u306b\u308f\u304b\u308b\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3068\u4e0a\u624b\u304f\u52d5\u4f5c\u3059\u308b\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<h2>\u95a2\u6570\u5f93\u5c5e\u6027\u304c\u52a9\u3051\u3066\u304f\u308c\u308b\u3053\u3068<\/h2>\n<p>\u3053\u3053\u3067\u554f\u984c\u3092\u6574\u7406\u3059\u308b\u3002<\/p>\n<ul>\n<li>\u578b\u30af\u30e9\u30b9\u306e\u3046\u3061\u3044\u304f\u3064\u304b\u306e\u578b\u5909\u6570\u306e\u578b\u304c\u5b9a\u307e\u308c\u3070\u4ed6\u306e\u578b\u5909\u6570\u306e\u578b\u304c\u81ea\u52d5\u7684\u306b\u5b9a\u307e\u308b\u5834\u5408\u304c\u3042\u308b<\/li>\n<li>\u30b3\u30f3\u30d1\u30a4\u30e9\u306f\u305d\u306e\u3088\u3046\u306b\u52dd\u624b\u306b\u578b\u3092\u5b9a\u3081\u308b\u3088\u3046\u306a\u52d5\u4f5c\u306f\u3067\u304d\u306a\u3044<\/li>\n<\/ul>\n<p>\u305d\u3053\u3067\u3001\u66f8\u304d\u624b\u5074\u304c\u30b3\u30f3\u30d1\u30a4\u30e9\u306b\u52dd\u624b\u306b\u578b\u3092\u5b9a\u3081\u3066\u826f\u3044\u3068\u3059\u308b\u3088\u3046\u306a\u8a18\u8ff0\u304c\u95a2\u6570\u5f93\u5c5e\u6027\u3067\u3042\u308b\u3002<br \/>\n\u95a2\u6570\u5f93\u5c5e\u6027\u3092\u3092\u8ffd\u52a0\u3059\u308b\u3068\u578b\u5909\u6570a, b\u306e\u578b\u304c\u5b9a\u307e\u3063\u305f\u3089\u305d\u3053\u304b\u3089\u5c0e\u304b\u308c\u308b\u578b\u5909\u6570c\u306e\u578b\u3092\u63a8\u8ad6\u3057\u3066\u3088\u3044\u3068\u3044\u3046\u898f\u5247\u3092\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<p>\u3053\u3053\u3067\u306f\u3001\u95a2\u6570\u5f93\u5c5e\u6027\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3067\u3001\u610f\u56f3\u901a\u308a\u306bm1 * m2\u306e\u7d50\u679c\u306e\u578b\u3092\u660e\u793a\u3059\u308b\u3053\u3068\u306a\u304fMatrix\u306e\u7d50\u679c\u3092\u5f97\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<h2>\u53c2\u8003\u60c5\u5831<\/h2>\n<p><a href=\"http:\/\/www.kotha.net\/ghcguide_ja\/7.6.2\/type-class-extensions.html#functional-dependencies\" title=\"http:\/\/www.kotha.net\/ghcguide_ja\/7.6.2\/type-class-extensions.html#functional-dependencies\">http:\/\/www.kotha.net\/ghcguide_ja\/7.6.2\/type-class-extensions.html#functional-dependencies<\/a><\/p>\n<p><a href=\" http:\/\/rf0444.hatenablog.jp\/entry\/20120513\/1336883141\" title=\" http:\/\/rf0444.hatenablog.jp\/entry\/20120513\/1336883141\"><br \/>\nhttp:\/\/rf0444.hatenablog.jp\/entry\/20120513\/1336883141<\/a><\/p>\n<p><a href=\"http:\/\/www.haskell.org\/haskellwiki\/Functional_dependencies\" title=\"http:\/\/www.haskell.org\/haskellwiki\/Functional_dependencies\">http:\/\/www.haskell.org\/haskellwiki\/Functional_dependencies<br \/>\n<\/a><\/p>\n<p>\u6ce8\u610f<\/p>\n<p>\u6700\u5f8c\u306eHaskellWiki\u306e\u60c5\u5831\u306b\u306f\u8aa4\u308a\u304c\u3042\u3063\u305f\u3002<\/p>\n<p>(m1 * m2) :: Matrix * m3    &#8212; this is ok<br \/>\n\u3068\u66f8\u3044\u3066\u3042\u308b\u304c\u3001\u3053\u308c\u306fOK\u3067\u306f\u306a\u3044\u3002<\/p>\n<p>\u5b9f\u969b\u578b\u3092\u898b\u3066\u307f\u308b\u3068\u3001c \u306e\u578b\u306f\u66d6\u6627\u306a\u307e\u307e\u3068\u306a\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u305f\u3081\u578b\u30a8\u30e9\u30fc\u3067\u3042\u308b\u3002<br \/>\n\u8aac\u660e\u5185\u5bb9\u306f\u4e0a\u624b\u304f\u66f8\u3044\u3066\u3042\u308b\u3088\u3046\u306b\u898b\u3048\u308b\u306e\u3067\u53c2\u8003\u60c5\u5831\u3068\u3057\u3066\u4e0a\u3052\u3066\u304a\u304f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3084\u3063\u3068\u5206\u304b\u3063\u305f\u6c17\u304c\u3059\u308b\u306e\u3067\u307e\u3068\u3081\u308b\u3002 \u95a2\u6570\u5f93\u5c5e\u6027\u3068\u306f\u4f55\u304b\uff1f Parsec\u30e9\u30a4\u30d6\u30e9\u30ea\u306a\u3069\u3092\u898b\u3066\u3044\u308b\u3068\u578b\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5ba3\u8a00\u306b\u95a2\u6570\u5f93\u5c5e\u6027\u304c\u8a18\u8ff0\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u3042\u308b\u3002 instance Moge a b c | a b -\u2026 <span class=\"read-more\"><a href=\"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/?p=84\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"class_list":["post-84","post","type-post","status-publish","format-standard","hentry","category-1"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4wwqG-1m","_links":{"self":[{"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=\/wp\/v2\/posts\/84","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=84"}],"version-history":[{"count":12,"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=\/wp\/v2\/posts\/84\/revisions"}],"predecessor-version":[{"id":96,"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=\/wp\/v2\/posts\/84\/revisions\/96"}],"wp:attachment":[{"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}