Month: January 2019

  • 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…