Monoid & MonoidK

In continuation to previous post. There is no documentation for MonoidK (Monoid for higher Kinds) on the cats site, hence let me try explaining it. Though Monoid first. Monoid `Monoid[T]` technically is a Semigroup with an `empty`/`Identity` function. i.e. There are two main properties: Associativity…

Cats

Cats is a simple and concise functional programming library for Scala. It appeals to me for its compactness and simpler class hierarchy. I have no formal education in category theory. But I am a student of theoretical Mathematics and have studied Abstract Algebra. Though I…

Type-information of generic type for a Parametrized class

Sometimes you feel that your code is world-class and deserves to be shared. There is one such class I have written for a personal project and find it to be extremely useful. You can view it here. Its called `CaptureType` This class obtains the type…

Hack Puzzle – 1

I have been thinking for quite some-time to build a puzzle. I think I have built an awesome one and hope everyone finds it awesome to hack You can download the jar from here. Aim: Make the program terminate gracefully Terminate gracegully: Implies that the program should…

Atomicity from single-cycle compare & swap

There is a wonderful function defined in scala.concurrent.Future trait called onComplete. Here is the declaration: There is one key-point in the documentation which says : If the future has already been completed, this will either be applied immediately or be scheduled asynchronously. The reason I call…

Issues with Java 7 on Mac OS

At my work place, I was involved in building a desktop application for Mac (priority) & Windows (lesser priority). So for about 5 months, I did all my development work on Mac and now I think I have a good feel of the OS. So…

Continuation….

This post is in continuation to the previous post – Co-variance and Contra-variance Arrays in Java are Co-variant. Which basically means if “String” extends “Object” then “String[]” also extends “Object[]”. Do you see  any pitfall’s above?? Lets look at the following example Example – 1…

Co-variance & Contra-variance

I have been working on Scala recently and it has been a pure pleasure. I am in love with the language. And Yes! it indeed is a beast. Generics/Parametrization is something that has always kept me on the hook even after good amount of experience…

Cache

This is  the first part of series of posts I plan to put-up on effective memory-centric cache implementations. Well I have been working and going through different cache implementations in Java. Below is a discussion on some of them. The aim is to choose the…

Another reason to love Neo4J

For one of the projects where Neo4J is being used, I have been working on implementing K-Shortest Path algorithm using Yen’s loopless improvised algorithm. Now an issue in the algorithm is that; Say  in computing top 4 shortest path, what the algorithm does is that…