<?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 Patrick Stapfer on Medium]]></title>
        <description><![CDATA[Stories by Patrick Stapfer on Medium]]></description>
        <link>https://medium.com/@ryyppy?source=rss-6e573535a3d0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iLNWKF9lN7sbxQAXxYS4qw.png</url>
            <title>Stories by Patrick Stapfer on Medium</title>
            <link>https://medium.com/@ryyppy?source=rss-6e573535a3d0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 05:12:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ryyppy/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[A Quick Look on my ReasonML Workflow with VSCode]]></title>
            <link>https://medium.com/@ryyppy/a-quick-look-on-my-reasonml-workflow-with-vscode-637685f9417a?source=rss-6e573535a3d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/637685f9417a</guid>
            <category><![CDATA[reasonml]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Patrick Stapfer]]></dc:creator>
            <pubDate>Wed, 02 May 2018 09:02:00 GMT</pubDate>
            <atom:updated>2018-09-10T13:22:48.948Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Update, 10.9.2018: </strong>This article has migrated to the newly recommended <a href="https://marketplace.visualstudio.com/items?itemName=jaredly.reason-vscode">VSCode plugin</a> by <a href="https://medium.com/u/ecb657c8b22d">Jared Forsyth</a>.</p><p><strong>The version of my toolchain on this date:</strong></p><ul><li>Reason 3.3.3 @ e10fa53</li><li>BuckleScript 4.0.5</li></ul><p><strong>Note:</strong> This article is aimed for beginners without any knowledge about Reason.</p><p>In April 2018, <a href="https://medium.com/u/ff3f225e7f5c">Nik Graf</a> and I were giving workshops at <a href="https://www.react-finland.fi/">React-Finland</a> and got some really good impressions on how newcomers learn to code in Reason for their very first time.</p><p>The tools in the Reason ecosystem are quite useful to learn the language itself, so I try to show you how I work on Reason code inside VSCode and the terminal, to make it easier for you to get started.</p><p>Luckily since August 2018, the installation steps got way easier with the new VSCode plugin done by <a href="https://medium.com/u/ecb657c8b22d">Jared Forsyth</a>.</p><p>What’s the major difference to the existing <a href="https://github.com/freebroccolo/ocaml-language-server/">ocaml / reason plugin</a>? You can read the motivation behind this <a href="https://github.com/jaredly/reason-language-server#what-about-ocaml-language-server">here</a>.</p><p>This is also the only plugin which works on Windows without any hacks, therefore makes it the official recommended way of developing Reason.</p><h4>Step 1— Installing the VSCode Reason Plugin</h4><p>Go to the extension tab and search the marketplace for a plugin called reason-vscodeby Jared Forsyth, press the install button and reload your VSCode instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iIQP3illUXFAtkOcFJ71yg.png" /></figure><p>Now your editor should be able to interact with Reason code. After an initial build with BuckleScript, you should be able to see type information on cursor hover, inferred types and also basic type errors. Also you will notice that *.re will have correct syntax highlighting.</p><h4>Step 2— Let’s try out the setup</h4><p>For the next steps, let’s check out a Reason / BuckleScript based project. For convenience, we will use the same repository I use for my workshops:</p><p><a href="https://github.com/ryyppy/reason-workshop">ryyppy/reason-workshop</a></p><p>Clone the repository and run npm install to install all necessary dependencies. Since bs-platform is defined as a devDependency, all the tools you need to compile Reason to JavaScript will also be installed inside your node_modules directory.</p><p>We already defined some convenience scripts inside package.json to easily interact with the BuckleScript compiler:</p><pre>&quot;scripts&quot;: {<br>  &quot;bs:clean&quot;: &quot;bsb -clean-world&quot;,<br>  &quot;bs:build&quot;: &quot;bsb -make-world&quot;,<br>  &quot;bs:watch&quot;: &quot;bsb -make-world -w&quot;<br>}</pre><p>So by running npm run bs:watch you will start the BuckleScript compiler in watch mode, actively recompiling Reason files (*.re) on each change. Since BuckleScript also offers better error messages than Merlin, let’s use the watch command inside the VSCode terminal itself:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qbkboeSbZ-tfyrlwKEmtFA.png" /></figure><p>In the screenshot above, you’ll see BuckleScript up and running in the bottom terminal pane. Whenever there is a type error in our code (after saving a file), the compiler will show nice error messages for troubleshooting:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q2YV96-XNDV2iaHzOq3kFA.png" /></figure><p>For me, I find it much easier to have BuckleScript running inside my VSCode, since I will never be required to switch from my IDE to my terminal. As soon as I adapted this workflow, I realized that my feedback loop was much quicker and I got a much more immersive coding experience.</p><p>Of course, there are many other tools which need to be run in the background, like webpack or a development server. I usually keep them in my separate terminal, because in most cases, errors only happen whenever BuckleScript doesn’t fully compile.</p><h4>Last Quick Tip: Reformatting</h4><p>Whenever you are editing a *.re file, you can run Shift-Option-F to reformat the editor buffer.</p><p>To try this, copy this code snippet in one of the reason files inside thesrc directory and hit the Shift-Option-F hotkey:</p><pre>let addAndStringify = (<br>  a,<br>  b) =&gt; {<br>let c = a + b;</pre><pre>string_of_int(c);</pre><pre>};</pre><p>The code should now be correctly formatted.</p><p>That’s it! After following these 2steps, you are now able to work on Reason code in VSCode.</p><p>If you have any problems with your setup, make sure to ask questions on our <a href="https://discord.gg/reasonml">Reason Discord</a> #editorsupport channel.</p><p>For more blog articles &amp; news about Reason and other web related programming languages, <a href="https://twitter.com/ryyppy">follow me on Twitter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=637685f9417a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Some Words about the ReasonConf Attendees and Community]]></title>
            <link>https://medium.com/reasonconf/some-words-about-the-reasonconf-attendees-and-community-5487436c875b?source=rss-6e573535a3d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/5487436c875b</guid>
            <category><![CDATA[reasonml]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Patrick Stapfer]]></dc:creator>
            <pubDate>Mon, 26 Mar 2018 08:08:57 GMT</pubDate>
            <atom:updated>2018-05-07T16:42:47.877Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ADlNlQE1QN6OMTVNsLWl-g.png" /></figure><p>The date for ReasonConf 2018 is coming closer but we still didn’t have the chance to talk about the Reason community and especially about the people you will meet at the conference.</p><p>Software and technology is only as strong as the people behind it. Building a productive and friendly ecosystem requires strong social and open source skills.</p><p>And let’s be honest here: especially in JavaScript, it’s quite hard to find the right candidate who satisfies all the technical, social and idealistic needs.</p><p>Let us explain why you, either as a company or individual, might be interested to join our conference and why it’s worth to be a sponsor.</p><p><strong>But first of all: What is Reason and why should I care as a company?</strong></p><p><a href="https://reasonml.github.io/">Reason</a> is a new language by Facebook, which is built on top of the reliable and established OCaml ecosystem. It’s especially popular in the ReactJS community, since it offers <a href="https://github.com/reasonml/reason-react">first class support for ReactJS</a> and is being used to <a href="https://reasonml.github.io/blog/2017/09/08/messenger-50-reason.html">develop the Facebook Messenger app</a>.</p><p>The Reason project tries to tackle several important pain points in the React &amp; JavaScript community:</p><ul><li>Make functional programming paradigms (like those in ReactJS) approachable for JS developers</li><li>Build even more type-safe programs than with other typed-JS tools like TypeScript &amp; Flow … This is especially important for mission critical software with no fault-tolerance</li><li>Offer performant &amp; optimized JS output, without many compromises</li><li>Bring and keep developers in the <a href="https://vimeo.com/180287057">Pit of Success</a></li></ul><p>You will find more technical details and why Reason might be a good fit for your company in another article called <a href="https://medium.com/@okonetchnikov/reasons-to-support-reasonconf-2018-bdbb281f38d">“Reasons to support ReasonConf”</a> by <a href="https://medium.com/u/5829a67c85f9">Andrey Okonetchnikov</a>.</p><p><strong>What companies care about Reason &amp; OCaml?</strong></p><p>There are many other big industries and companies leveraging the OCaml (and partly Reason) platform, such as Bloomberg, Facebook, JaneStreet, Docker, Citrix, Issuu and <a href="https://ocaml.org/learn/companies.html">many more</a>.</p><p>We were really surprised when <a href="https://www.accenture.com/at-de/new-applied-now">Accenture</a>, one of the biggest consulting agencies in the world, reached out to us and said they want to sponsor us. After we thought about it and talked to them, we realized that keeping track of emerging technologies is key to get ahead of competitors and outperform them on the long run.</p><p><strong>Now let’s talk about the community and conference attendees</strong></p><p>There will be around 180 attendees at the conference. Most of them are fluent with ReactJS and also see the bad parts of pure JavaScript codebases. They are enthusiastic about technology and put a considerable amount of time and effort to make the Reason ecosystem better on every release.</p><p>The background of our community members is vast. Many of them were on the lookout for a functional language which is also more approachable for their coworkers. They tried Haskell, ClojureScript, PureScript, Elm, Scala, Elixir and other similar languages, which don’t really fulfil the aspect of being “JavaScripty” enough to be easily understood by their colleagues. Luckily for us, some of them got stuck with Reason.</p><p>They build things like type-safe GraphQL queries with <a href="https://github.com/apollographql/reason-apollo">Reason-Apollo-GraphQL</a> or highly efficient, natively compiled, single executable <a href="https://github.com/andreas/ocaml-graphql-server">graphql-servers</a>, which are also preventing essential runtime bugs and outperform Node.js with ease.</p><p>Also there are efforts on building a natively compiled, slimmer version of webpack, called <a href="https://github.com/fastpack/fastpack">fastpack</a>. Other projects like <a href="http://esy.sh/">Esy</a> try to eliminate unacceptable build times of native dependencies in a CI environment. Esy is a package-manager designed for building, tracking and caching native dependencies in JS and OCaml projects, while being compatible with the npm workflow.</p><p>As the conference organizers, we have a personal interest to get as many of these great minds in one place, since we are also contributing to the Reason project and want to get the most out of it.</p><p>We invited experts such as Cheng Lou (Facebook), Jared Forsyth (Khan Academy), Keira Hodgkison (Culture Amp), Cristiano Calgagno (FB Infer Project), Sven Sauleau (Babel), and many more — to educate and inspire our attendees.</p><p>We believe that most of our attendees are interested in complex technical challenges and are motivated to push forward technical innovation for better products and better engineering.</p><p><strong>So what’s the progress?</strong></p><p>The organization of <a href="https://www.reason-conf.com/">ReasonConf 2018</a> is coming along quite nicely so far. We finalized the <a href="https://www.reason-conf.com/schedule/">schedule</a>, booked the flights and hotel for our <a href="https://www.reason-conf.com/speakers/">speakers</a> and also made sure that we have a really nice <a href="https://www.reason-conf.com/attendees/">venue</a> for all 3 days.</p><p>There are a few ideas which we can only make happen with stronger financial support, therefore we are looking for sponsors to make this event awesome.</p><p>By <a href="https://www.reason-conf.com/sponsors/">sponsoring our event</a>, you will not only get in touch with highly talented JavaScript / ReactJS engineers, but you will also give your employees an opportunity to learn about upcoming web technologies in the heart of Vienna.</p><p>If you are interested, please get in touch.</p><p><strong>Email:</strong> hi@reason-conf.com<br><strong>Website:</strong> <a href="https://www.reason-conf.com/">https://www.reason-conf.com</a></p><p>Patrick, Nik and Andrey</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5487436c875b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/reasonconf/some-words-about-the-reasonconf-attendees-and-community-5487436c875b">Some Words about the ReasonConf Attendees and Community</a> was originally published in <a href="https://medium.com/reasonconf">ReasonConf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shipping Flowtype Definitions in NPM Packages]]></title>
            <link>https://medium.com/netscape/shipping-flowtype-definitions-in-npm-packages-c987917efb65?source=rss-6e573535a3d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/c987917efb65</guid>
            <category><![CDATA[flowtype]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[npm]]></category>
            <dc:creator><![CDATA[Patrick Stapfer]]></dc:creator>
            <pubDate>Tue, 29 Nov 2016 15:07:12 GMT</pubDate>
            <atom:updated>2016-11-29T21:48:58.414Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*dzGrkpmwrlt3A3CecEaC2A.png" /></figure><p>It’s super awesome to see a <a href="https://github.com/graphql/graphql-js">lot</a> of <a href="https://github.com/styled-components/styled-components">libraries</a> starting to adopt <a href="https://flowtype.org/">flow</a> to add type-safetiness to their code…</p><p>BUT… what a lot of people forget is that npm packages usually ship ES5 code without any type information and in the end, the consumer of this library will only get any as imported types.</p><p>While working on the typings in styled-components, I have been looking for a guide on how to expose flow types for the user the right way and realized that there wasn’t any yet.</p><p>So this article aims to give library maintainers some guidelines / ideas on how to vendor flow definitions within the npm build process.</p><p>As a reference project, I created a <a href="https://github.com/ryyppy/medium-expose-flow-types">repository</a> with some bare bone package setup and some example code.</p><p>We will go through the setup step-by-step and also talk a little bit about some flow specific mechanics, e.g. how flow imports files.</p><h4><strong>So let’s get started!</strong></h4><p>Our example library <a href="https://github.com/ryyppy/medium-expose-flow-types/blob/master/package.json">my-lib</a> consists of a src directory with some ES6 source code:</p><pre>$ tree src<br>src<br>├── index.js<br>└── util<br>    ├── __tests__<br>    │   └── reduceChainPromises-test.js<br>    └── reduceChainPromises.js <strong>&lt;-- showcasing a nested subdir</strong></pre><p>As maintainers we usually want to distribute our code as…</p><ol><li>… web compatible format (UMD, AMD,…) in dist</li><li>… ES5 compiled source in lib (keeping the file structure of src)</li></ol><p>We will completely ignore case 1, since as for right now, there is no easy way to expose type information for a single compiled file (except for writing a <a href="https://github.com/flowtype/flow-typed">libdef</a> file). In this article, we will focus on 2, how to make flow recognize types for files shipped in lib.</p><p>In our first step, we will install all necessary devDependencies to get our build chain going:</p><pre>npm install babel-cli babel-core babel-preset-es2015 babel-plugin-transform-flow-strip-types flow-copy-source rimraf --save-dev</pre><p>If you have already been using babel, then you are probably familiar with most of these dependencies. The babel plugin babel-plugin-transform-flow-strip-types will make sure that all flow related code will be stripped out in our compiled ES5 code.</p><p>Additionally, we install rimraf for running rm -rf commands and flow-copy-source to easily create so-called “flow-files”, which will be explained later on.</p><p>The most interesting part is, that all our tools are running on node so we don’t have to worry about any Windows / OSX / Linux development setups.</p><p>For completeness, here is our .babelrc:</p><pre>{<br>  &quot;presets&quot;: [&quot;es2015&quot;],<br>  &quot;plugins&quot;: [&quot;transform-flow-strip-types&quot;]<br>}</pre><p>Alright, now babel understands ES6 + flow syntax! Let’s go through our <a href="https://github.com/ryyppy/medium-expose-flow-types/blob/master/package.json#L6-L11">package.json</a> scripts next:</p><pre>{<br>  &quot;name&quot;: &quot;my-lib&quot;,<br>  ...<br>  &quot;scripts&quot;: {<br>    &quot;test&quot;: &quot;jest&quot;,<br>    &quot;build&quot;: &quot;npm run build:clean &amp;&amp; npm run build:lib &amp;&amp; npm run    <br>              build:flow&quot;,<br>    &quot;build:clean&quot;: &quot;rimraf lib&quot;,<br>    &quot;build:lib&quot;: &quot;babel -d lib src --ignore &#39;**/__tests__/**&#39;&quot;,<br>    &quot;build:flow&quot;: &quot;flow-copy-source -v -i &#39;**/__tests__/**&#39; src lib&quot;<br>  }<br>  ...</pre><pre>}</pre><p>In our scripts section, we can find thebuild instruction, which will do three things:</p><ol><li>npm run build:clean: Removes the current lib directory</li><li>npm run build:lib: Builds lib from scratch by compiling src via babel</li><li>npm run build:flow : Creates our flow-files, which are also put into lib</li></ol><p>Step 3) is relevant for our goal… we call flow-copy-source which will (by default) copy all *.js files in src and copy them into the target directory lib , preserving the original directory hierarchy. Those files will have a different file-ending, called *.js.flow.</p><blockquote><strong>Side Note:</strong><br>I am using <a href="https://facebook.github.io/jest/">jest</a> for testing, that’s why I added ignore rules for **/__tests__/** globs. I don’t want test files to land in lib.</blockquote><p>Here is a listing of our resulting lib after running npm run build:</p><pre>$ tree lib<br>lib<br>├── index.js<br>├── index.js.flow <strong>&lt;-- Exact same content as src/index.js</strong><br>└── util<br>    ├── reduceChainPromises.js<br>    └── reduceChainPromises.js.flow</pre><h4><strong>Introducing “flow-files” (*.js.flow)</strong></h4><p>So if there is a file src/util/reduceChainPromises.js, the whole file will be copied to lib/util/reduceChainPromises.js.flow … but why do we need that?</p><p>Flowtype resolves modules the same way as node does. If you are importing my-lib/lib/util/reduceChainPromises, you would probably do it like this:</p><pre><strong>import</strong> reduceChainP <strong>from</strong> &#39;my-lib/lib/util/reduceChainPromises&#39;;</pre><p>By default, flow will look into node_modules/my-lib and try to find the file lib/util/reduceChainPromises. But wait! Files in lib only contain pure ES5 code, so we loose our type information (flow will most likely treat reduceChainP as type any).</p><p>Luckily, if flow finds files with a *.js.flow file ending, it will prefer it over the actual *.js. So we vendor additional files, which will only tell flow what types are exposed in the accompanied ES5 file. Since these files are generated in our build process, we can always be sure that our flow-files are synced up with the actual code.</p><h4>What about the file bloat?</h4><p>You will probably argue that copying the whole src files to lib will unnecessarily bloat the resulting npm package, right? The flow team is aware of that issue and is working on an experimental command called flow gen-flow-files:</p><pre>$ flow gen-flow-files --help<br>Usage (EXPERIMENTAL): flow gen-flow-files [OPTIONS] [FILE]</pre><pre>e.g. flow gen-flow-files ./src/foo.js &gt; ./dist/foo.js.flow</pre><p>As soon as this feature is stable, we will be able to extract pure type information from our ES6 code, and put those type information in our *.js.flow, ultimately stripping the implementation code (kinda like the invert of what babel does to our src files).</p><p>Okay nice, so we now have a build system which will generate backwards compatible ES5 code <strong>AND</strong> add type definitions for our library, ready to be used by the consumers.</p><h4><strong>This was just a very basic introduction to this topic.</strong></h4><p>There are still a lot of open questions:</p><ul><li>What about dependencies for our library?</li><li>What about dependency collisions with our library (e.g. lodash)?</li><li>What about different flow versions between the consumer &amp; my library?</li></ul><p>As soon as I find some time, I will do some follow up articles where we will deep dive into these problems and discover how to solve them as well!</p><p>You can check out our <a href="https://github.com/styled-components/styled-components/blob/master/docs/flow-support.md">flow-support docs</a> on styled-components to see how a more complex library is being typed and shipped with flow.</p><p>For questions or more updates on Flowtype leave me a tweet or follow me on Twitter <a href="https://twitter.com/ryyppy">@ryyppy</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c987917efb65" width="1" height="1" alt=""><hr><p><a href="https://medium.com/netscape/shipping-flowtype-definitions-in-npm-packages-c987917efb65">Shipping Flowtype Definitions in NPM Packages</a> was originally published in <a href="https://medium.com/netscape">Netscape</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>