Posts

Showing posts from April, 2017

Free Monad: Discussion on when to use it, maybe you are using it already but don't know it!

Free Monads are popular these days but they are still not in widespread use primarily because of their syntatic complexity and high abstraction level. Free monads allow you to operate in monadic structures with "commands" or "instructions" that mimic imperative programs. Imperative programming is fairly easy as each instruction is sequenced and tracing the flow of logic is mostly easy. However, in reactive programming for example web programming that involves "callbacks", it is much harder to trace the time-based sequencing because callbacks can be called at any time. This is especially true in high-latency enviroments such as the internet. If we skip the concept of free monads for a moment, we see that no matter where we look, when we program in a complex enviroment like the internet, we often create Domain Specific Languages to deal with the complexity. In both c# and scala, as well as javascript to some degree, the concepts of async/await have been in…

typescipt, clojurescript, flow, scalajs, haskell and other type-oriented javascript transpilers

It is well known that it can be difficult to develop javascript applications due to the lack of a static typechecking transpilation stage. While it is a strength that javascript is typeless, many types of programming tasks and applications greatly benefits from typechecking. There are good reasons to completely ignore static type checking, such as in most javascript programs or clojurescript programs. However, even common lisp has static (and dynamic) type checking (it's not well known that the compiler can type check).

Typescript, adopted and promoted by the google angular team, has become very popular especially in the past few months. Its been organically growing for many years and its a good example of Microsoft contributing to the open source community. Typescript is a light layer on top of javascript that allows you to typecheck your programs. Perhaps some of the features in typescript will be moved into the javascript standard, perhaps not. Flow, facebook's typechecker,…

React, Redux, Recompose and some simple steps to remove "some" boilerplate and improve reuse

Image
Most of the documentation around react+redux centers around using pure components andredux.connectto connect up the pieces. However, sometimes you may want some very local state that is not really application state and its just easier to use the local react state. In other words, you need to wrap a pure component, keep it pure, but still somehow, wrap some local state around it. For example, I want to create a table showing a list and I want to highlight the hover row. There are many ways to do this, for example using CSS, but another way to do this is to use some local state to store the "hovered" row. Hovering is an intense activity and is not critical for communicating with other UI components or business logic. We could whip outreact-uiwhich provides a way to manage block-scoped state. For our case though we just want to highlight the moused-over row in a list and there are no other connections or functionality that is tied to the "hovered" item in the list so…