The always learning Marty’s software engineering journey

  • Recursion: An Indispensable Tool For Every Functional Programmer [Example With Insertion Sort]

    This is the first of a series of articles that illustrates functional programming (FP) concepts to imperative programmers. As you go through these articles with code examples in Haskell (one of the most popular FP languages), you gain the grounding for picking up any FP languages quickly. Why should you care about FP? See this…

  • Why you should learn functional programming

    Why you should learn functional programming Many of the widely used languages (including C++, Java, and Javascript) are imperative.  In imperative programming, computations are structured as sequences of instructions that operate by making modifications to the state of the program.  Functional languages operate by declaring functions. The output value of a function depends only on…

  • Dependent types: formal definition and examples

    Dependent types: formal definition and examples

    Dependent types have been gaining a lot of attention among programmers. Some would say it’s “the next thing” in programming. Why is it gaining popularity? In this post, I hope to show some of the advantages of dependent types and get you started on programming in dependent types. To understand dependent types, let’s take a…

  • Smart Contract Language Design: Reflections from Devcon 5

    Here at Cryptium Labs, besides delegation services and protocol development, we are also developing a smart contract language called Juvix. A few talks I went to at Devcon 5 have me reflecting on some thoughts of smart language design. I’d like to tie them up with our Juvix work and share them in this post.…

  • Programming with Envelopes in OCaml and Haskell

    Programming with Envelopes in OCaml and Haskell

    In this post, I continue going through the famous paper “Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire” by Meijer et al.  They show that we can treat recursions as separate higher order functions known as recursion schemes.  Each of the four things in the paper title corresponds to a type of recursion scheme. …

  • Zip and More in Haskell

    Zip and More in Haskell

    In the last post we talked about using unfolds to zip and more in OCaml. In this post we write the equivalent functions in Haskell. Zip is in the standard library in Haskell. It’s actually so elegant that there isn’t much point using unfolds instead. To zip two lists, simply use the zip function: Prelude>…

  • Using Unfolds to Zip and More in OCaml

    Using Unfolds to Zip and More in OCaml

    This post picks up from where we left off here, where I explained anamorphisms.  In the last post we looked at iterating with anamorphisms.  Here we look at another example of applying unfolds: zip. Zip Zip may not be the most common example of anamorphisms but I want to cover it because it’s included in…

  • Using Unfolds to Iterate in Haskell and OCaml

    Using Unfolds to Iterate in Haskell and OCaml

    This post picks up from where we left off here, in which I explained anamorphisms.  Here we look at another example of applying unfolds: iterate.  Iterate Iterate is one of the most common uses of unfold.  The definition of the iterate function is: iterate f x = Cons (x, iterate f (f x)) E.g., let…

  • Why Blockchain Engineers Should Learn Functional Programming

    Why Blockchain Engineers Should Learn Functional Programming

    As a software engineer who wants to work with blockchains, you may ask: what languages should I learn?  Answers on the internet (e.g., here, here, and here) mostly recommend prominent languages like C++, Python, Java, and Javascript, and the smart contract language Solidity.  None of them mention any functional languages!  In this post I’ll explain…

  • Programming with Lenses in Haskell and OCaml

    Programming with Lenses in Haskell and OCaml

    In this post, I continue going through the famous paper “Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire” by Meijer et al.  They show that we can treat recursions as separate higher order functions known as recursion schemes.  Each of the four things in the paper title corresponds to a type of recursion scheme. …