<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Adrián Ferreyra on Medium]]></title>
        <description><![CDATA[Stories by Adrián Ferreyra on Medium]]></description>
        <link>https://medium.com/@_AdrianFerreyra?source=rss-645457bb2402------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FPcPXpWAEOcOO-ppqCtoww@2x.jpeg</url>
            <title>Stories by Adrián Ferreyra on Medium</title>
            <link>https://medium.com/@_AdrianFerreyra?source=rss-645457bb2402------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 03:02:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@_AdrianFerreyra/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why did the entire iOS Developer community just forget about functional programming?]]></title>
            <link>https://medium.com/@_AdrianFerreyra/why-did-the-entire-ios-developer-community-just-forget-about-functional-programming-65449dc5065d?source=rss-645457bb2402------2</link>
            <guid isPermaLink="false">https://medium.com/p/65449dc5065d</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Adrián Ferreyra]]></dc:creator>
            <pubDate>Thu, 09 Mar 2017 14:17:53 GMT</pubDate>
            <atom:updated>2017-03-09T14:22:16.800Z</atom:updated>
            <content:encoded><![CDATA[<p>I’m one of those guys who still remember it. I remember everyone going crazy trying to find out what a monad is. I remember Haskell blogs peaking up their view counters, and books that were long archived being dig out and read over and over again. I remember a whole community trusting a single thought: “This is different. This can fix every single problem we have. This is the future (though it comes from the past ¯\_(ツ)_/¯)”.</p><p>N️ow, something definitely went wrong. I mean, there are still people who are into functional programming, but the scene is definitely different to what it was two or three years ago. Did we learn something from all this? Did we found it too hard?</p><p>In my opinion, the current situation is a result of several factors working together. First of all, this whole thirst for functional programming techniques reviving was not an iOS community idea. This is something that the whole software community was growing (and enhancing) from the moment that Scala started taking Java popularity off. Yeah, we all agree that hiring Scala Devs is way more difficult and expensive that hiring java junior Devs, but I think the need of start facing some issues in a more “serious way” (not just sitting a bunch of junior Java Devs to code like chimps) started moving the spotlight to anything that could guarantee (or at least, bring hope) professionalism and quality.</p><blockquote>…even having the correct tools, doesn’t guarantee that people will go that way.</blockquote><p>Now, obviously, the fact that we, iOS Devs, were working with Obj-C for like ages, also brought the idea that anything new would be better (do you remember untyped collection types?). Swift brought some sort of a fresh start, and it’s very first design (though the community effort has made incredible changes and improvements on that first conception) was good enough to find it exciting. And remember that that first approach already carried those functional programming concepts with it.</p><p>So what went wrong? I mean… Did something went wrong?</p><p>IMO, this case proves that even having the correct tools, doesn’t guarantee that people will go that way. I remember being really pissed of the moment Swift 3 removed currying functions (something I really like). But again, I understood the point out of it: Some concept or tool is worthless if the whole community does not agree that this is the right way to do. This has something to do with a much more “foundation” concept in software development: You have to work as a team.</p><p>There are some interesting functional programming cases, too. I love what <a href="https://twitter.com/mbrandonw">Brandon Williams</a> did with the Kickstater iOS app (<a href="https://github.com/kickstarter/ios-oss">here</a>). I find it beautiful, even though I agree with some of my colleagues that consider this project to be “way too complicated to add new people to the team”. And, if a project can’t easily grow it’s team and capabilities, is it a good project? I’m just thinking…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65449dc5065d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use the force, Luke… The force of Monoids in Swift.]]></title>
            <link>https://medium.com/@_AdrianFerreyra/use-the-force-luke-the-force-of-monoids-77dd588be384?source=rss-645457bb2402------2</link>
            <guid isPermaLink="false">https://medium.com/p/77dd588be384</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[monoids]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Adrián Ferreyra]]></dc:creator>
            <pubDate>Mon, 02 Mar 2015 10:34:27 GMT</pubDate>
            <atom:updated>2015-03-06T14:58:10.229Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*SSQfNxx0HsxuVu4BRT6njg.jpeg" /></figure><p>Monoids are, in fact, a great tool from Mathematics applied to programming. They let us define this kind of theorical structure, and guarantees us that if we follow this rules, we can not be wrong.</p><p>There are plenty of definitions of monoids over the web. Some of them more Maths related, like <a href="http://en.wikipedia.org/wiki/Monoid">this</a>, some others more programming related, like <a href="http://learnyouahaskell.com/functors-applicative-functors-and-monoids">this</a>. I’m not trying to explain the whole background here, because it’s way to heavy. Monoids are supposed to comply with some rules mathematically speaking, but we’re not interested in that here. You can get that info from around the web. What I want to do is give a plain, simple example of usage over Swift.</p><p>What Monoids define is “given a set of this, define a composition operation that guarantees that the result will also be in that set”. That’s it. Maybe you’ve heard of definitions like that in Maths.</p><p>The thing is, the very definition of Monoids talks about “a set of things”. It doesn’t tell you what those things are supposed to be. It just doesn’t care.</p><p>So, let’s say that we have our domain of functions that takes an int and returns an int:</p><p>typealias functionType = Int -&gt; Int</p><p>And we define a composition operation that given two Ints, returns the product of them.</p><blockquote>func multiply(intA: Int, intB: Int) -&gt; Int {</blockquote><blockquote>return intA * intB</blockquote><blockquote>}</blockquote><p>Theoretically, that’s all we need for defining the Monoid. Integers under multiplication are a Monoid.</p><p>And what do we achieve by doing that? Maybe this example is not that useful, but what’s happening here is that when we compose our set-compliant elements over our operation, <strong><em>we guarantee that the result will be in our set. There’s no way that we can get anything else.</em></strong></p><p>This definition can be made over functions, data types, objects. All you have to think about is how to combine this elements from the set to get another element from the set. A little bit of thinking, and you have Maths helping you design software.</p><p>Consider monoids next time you have to design functionality. Remember: if you do it, It can’t go wrong.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77dd588be384" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Currying in Swift]]></title>
            <link>https://medium.com/@_AdrianFerreyra/currying-in-swift-59657f4e533e?source=rss-645457bb2402------2</link>
            <guid isPermaLink="false">https://medium.com/p/59657f4e533e</guid>
            <dc:creator><![CDATA[Adrián Ferreyra]]></dc:creator>
            <pubDate>Thu, 06 Nov 2014 20:24:56 GMT</pubDate>
            <atom:updated>2014-11-06T20:32:35.027Z</atom:updated>
            <content:encoded><![CDATA[<p>Programming is an art. It’s understanding reality and making models of our understanding. It’s about proposing solutions to real world problems, by getting each interacting part of it and they way they do. So, when we talk about paradigms, we’re talking about the basis of theory that we take to think situations. Paradigms has been around for years, proposing ways of thinking and letting us focus straight on the problem that matters to us, rather than in the theory context.</p><p>With <strong>Swift</strong>, as with other modern programming languages as <strong><em>Scala</em></strong> for example, the paradigmatic focus has move from straight (or almost straight) OO thinking to a more functional paradigm thinking. And I’m using the word “more” because modern languages does not propose a fully pure paradigmatic approach,such as <strong><em>Haskell</em></strong> did, but a mixture of concepts and ideas from many approaches. It give us new tools to think problems in new ways, narrowing our limits.</p><p>I’d like to talk about one of that concepts, and thats <strong>currying</strong>. Currying a function (also known as “partially applying a function”) is a really simple concept inherited from the basis of FP, and that is math. The idea is to take a function that takes many arguments and “fix” a value on one of them. The result you’ll get from this process is a new function with, of course, one less argument.</p><p>Now you might be thinking “How is this useful?”. The thing is that curried functions are really useful in a functional environment where you don’t think about code imperatively. It’s useful if you are thinking your solution in terms of functional programming, not imperative programming. So, to really understand and follow up the idea, you have to think about declaring your code to achieve something, not to tell it what to do. When using a curried function, you don’t have to think about managing variables and passing them through your functions. Mathematically speaking, your function domain is narrow and safe.</p><h4>The Cans and Can’ts about Currying in Swift</h4><p>unfortunately, for those who come from a hard background in Haskell, functions in Swift are not high-ordered by default. What do I mean? In Haskell, every single function takes exactly one argument. So, for working with more than one argument per function (a completely normal scenario), you count on currying high-order functions to get more specific ones. MAP, FILTER, among others are examples of basic but really powerful high-order functions in Haskell.</p><p>But Swift is not Haskell. So, we can think in our situations in terms of closures. Closures let us define and return a function. So, by defining a function that takes an argument and encapsulates it into a close, we can return that close in order to call it later and do whatever we want with it.</p><p>So, we can approach currying as the following:</p><pre>func addTwoIntsCurried(a: Int) -&gt; (Int -&gt; Int) {</pre><pre>return {b in a + b}</pre><pre>}</pre><p>So here we’re writing down our bare concept. Our function takes an Int, creates a closure (where our first parameter is encapsulated, because that’s the definition of closure vs a lambda expression) and returns this “function” that takes another Int and returns a final Int with these numbers addition.</p><p>But here’s the thing. Swift already gives us some syntax sugar that comes in handy when you need to declare a curried function.</p><pre>func addTwoIntsCurried(a: Int)(b: Int) -&gt; Int {</pre><pre>return a + b</pre><pre>}</pre><p>just by declaring a parameters between separated parenthesis and not just in one big parenthesis, we are saying Swift that we want to pass the function an argument and get a function that encapsulates it.</p><p>Now, if you run the code I’ve just written up here and call it, let’s say, this way</p><pre>addTwoIntsCurried(3)(5)</pre><p>You’ll see that it gives us an error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*SHwpD6cK5xm-MQcey5DMxQ.png" /><figcaption>We’re still on β!</figcaption></figure><p>And that’s because this currying syntax of Swift presents a bug when it comes to anonymous parameters. <strong>When you call the result of a curried function, you have to declare the argument’s name. </strong>Even if you declare an empty name for the argument, you’ll still get it. You can follow a stackoverflow question about it <a href="http://stackoverflow.com/questions/24170906/why-do-curried-functions-require-external-parameter-names">here</a>.</p><p>I hope it helps! For any questions, contact me <a href="https://twitter.com/_AdrianFerreyra">on twitter</a>.</p><p>cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59657f4e533e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>