{"@attributes":{"version":"2.0"},"channel":{"title":"Chris Krycho - haskell","link":"http:\/\/v4.chriskrycho.com\/","description":{},"lastBuildDate":"Sun, 17 Jan 2016 10:00:00 -0500","item":{"title":"\u201cI Don't Know When I'd Use That\u201d","link":"http:\/\/v4.chriskrycho.com\/2016\/i-dont-know-when-id-use-that.html","description":"<p>I was reading an interesting Stack Overflow <a href=\"http:\/\/stackoverflow.com\/questions\/21170493\/when-are-higher-kinded-types-useful\">discussion<\/a> of the value of <a href=\"http:\/\/stackoverflow.com\/questions\/6246719\/what-is-a-higher-kinded-type-in-scala\">higher-kinded types<\/a> (hereafter <abbr>HKTs<\/abbr>), and noted someone repeatedly commenting, \u201cBut when would you use this in a <em>real app<\/em>?\u201d To put it the way another <a href=\"https:\/\/m4rw3r.github.io\/rust-and-monad-trait\/\">blog post<\/a> about <abbr>HKTs<\/abbr> (in Rust), they are \u201ca feature people do not really know what to do with.\u201d<\/p>\n<p>Don\u2019t get me wrong: I\u2019m sympathetic to that desire for concrete examples. I\u2019m interested in these kinds of things not primarily for their intellectual value but for their pragmatic value (though I don\u2019t think those two are as distinct as many people do). I\u2019d <em>also<\/em> love to see some more real-world examples in those discussions. All too often, the discussions of types in Haskell end up being quite abstract and academic\u2014no surprise, given the language\u2019s origin. But I\u2019m also aware that quite often it\u2019s difficult to see how a given kind of abstraction is useful without jumping into a language which has that abstraction available and <em>using<\/em> it.<\/p>\n<p>People often get turned off by Haskell (and other similarly high-abstraction languages like Scala) because of challenging terms like <em>monad<\/em>, <em>applicative<\/em>, <em>functor<\/em>, and so on. And again: I get that. To grok Haskell, you need to wrap your head around a lot of <em>math<\/em> ideas\u2014mainly various properties of <em>sets<\/em>.<\/p>\n<p>But I remember feeling the same way six years ago when I started playing with JavaScript and jQuery and every tutorial out there simply assumed existing familiarity and comfort with functions as arguments or return values. Coming from the world of Fortran and C, my head ached for weeks as I tried to make sense of what I was seeing. Even when I finally got it, <em>I didn\u2019t like it<\/em>. Over the last several years, though, I\u2019ve become increasingly comfortable and even reliant on closures, composition of functions to transform data, and so on as I worked regularly in Python and JavaScript.<\/p>\n<p>That experience has taught me that my current inability to see the utility of a given abstraction means little about the abstraction. It\u2019s primarily an indicator of my own inexperience.<\/p>\n<p>To the question of the utility <abbr>HKTs<\/abbr> in general\u2014in Haskell, Rust, or somewhere else\u2014I don\u2019t have the knowledge myself (yet) to supply a good answer. Heck, I can\u2019t even <em>explain<\/em> them very well. (<a href=\"http:\/\/adriaanm.github.io\/research\/2010\/10\/06\/new-in-scala-2.8-type-constructor-inference\/\">Other people can, though!<\/a>) But I can say that reading <a href=\"https:\/\/gumroad.com\/l\/maybe-haskell\"><em>Maybe Haskell<\/em><\/a> showed me clearly that such things can be very useful. Even if I am not yet comfortable using that tool, I see how learning to use it would be profitable in the long-term. And like any good tool, even if you don\u2019t need it every day\u2026 when you want it, you <em>really<\/em> want it.<\/p>\n","pubDate":"Sun, 17 Jan 2016 10:00:00 -0500","guid":"tag:v4.chriskrycho.com,2016-01-17:\/2016\/i-dont-know-when-id-use-that.html","category":["software development","programming languages","rust","haskell"]}}}