Posts

  • Futures in TypeScript

    In functional programming Promises are not the norm for async communications. The datatype Future is far more wide spread. This will be my try to implement a basic Future in TypeScript.

  • Fun With Catamorphisms

    The word cata (ancient Greek: κατά “down from”) + morphism (ancient Greek: μορφή “form, shape” ) is used to describe a way to collapse a recursive data structure into a new value based on its structure. fold defined for a list gives you a hint of what a catamorphisms is able to do. It is a very powerful thing to define for any structure since all other functions can be defined in terms of it. The closest equivalent in Object Oriented programming is perhaps the visitor pattern.

  • Different implementations of map

    The first way is to simply create a new list and mutate it by adding elements to it.

  • Maybe TypeScript

    Maybe är en datastruktur som är rätt så praktisk att ha. Man använder den när det inte är säkert att det finns någon data men man vill inte göra specialfall som kollar om så är fallet. I många funktionella språk så används den som returtyp där vanliga språk hade haft möjligheten att returnera null