Today we are going to tell you why we write frontend in Haskell and compile it to JavaScript. As a matter of fact, such a process is called transpilation:
Transpilation is the process of transforming the program written in language X into the equivalent program in language Y. In contrast to compilation, languages X and Y have roughly the same level of abstraction.
In general, transpilation can serve the following main purposes:
Let’s give some examples:
As you can see from the examples above, the discussion of transpilation in general inevitably brings up the subject of translation into JS. Let’s consider its purposes and potential benefits in more detail:
We selected the frontend development tools considering the following factors:
At present, here at Typeable we develop frontend in Haskell and use the web framework Reflex and the functional reactive programming (FRP). The source code in Haskell is transpiled into the JavaScript code using GHCJS.
The TypeScript and other JS extensions don’t work well for us as they offer weaker typing and their type system is not sufficiently developed as compared with Haskell. In general, these languages differ too drastically from those our team got accustomed to.
We’ve opted for Reflex instead of such alternatives as Elm and PureScript – first of all because we wanted to use the same development stack as for the backend. Moreover, Reflex saves you the trouble of following a specific application architecture and, to some extent, is more flexible and “low-level”. A detailed comparison of Elm and Reflex can be found in our post on the subject.
We were able to gain the benefits of JS transpilation we described above:
servant
library that allows us to describe API at the type level and check during the compilation whether both the server handlers and the client functions use correct parameters of the required types and correspond to the current API version (if you forgot to change the client function at the frontend, it just won’t be built).Surely, some difficulties do exist:
Typeable OU ("us", "we", or "our") operates https://typeable.io (the "Site"). This page informs you of our policies regarding the collection, use and disclosure of Personal Information we receive from users of the Site.
We use your Personal Information only for providing and improving the Site. By using the Site, you agree to the collection and use of information in accordance with this policy.
While using our Site, we may ask you to provide us with certain personally identifiable information that can be used to contact or identify you. Personally identifiable information may include, but is not limited to your name ("Personal Information").
Like many site operators, we collect information that your browser sends whenever you visit our Site ("Log Data").
This Log Data may include information such as your computer's Internet Protocol ("IP") address, browser type, browser version, the pages of our Site that you visit, the time and date of your visit, the time spent on those pages and other statistics.
In addition, we may use third party services such as Google Analytics that collect, monitor and analyze this ...
Cookies are files with small amount of data, which may include an anonymous unique identifier. Cookies are sent to your browser from a web site and stored on your computer's hard drive.
Like many sites, we use "cookies" to collect information. You can instruct your browser to refuse all cookies or to indicate when a cookie is being sent. However, if you do not accept cookies, you may not be able to use some portions of our Site.
The security of your Personal Information is important to us, so we don't store any personal information and use third-party GDPR-compliant services to store contact data supplied with a "Contact Us" form and job applications data, suplied via "Careers" page.
This Privacy Policy is effective as of @@privacePolicyDate and will remain in effect except with respect to any changes in its provisions in the future, which will be in effect immediately after being posted on this page.
We reserve the right to update or change our Privacy Policy at any time and you should check this Privacy Policy periodically. Your continued use of the Service after we post any modifications to the Privacy Policy on this page will constitute your acknowledgment of the modifications and your consent to abide and be bound by the modified Privacy Policy.
If we make any material changes to this Privacy Policy, we will notify you either through the email address you have provided us, or by placing a prominent notice on our website.
If you have any questions about this Privacy Policy, please contact us.