Category Archives: Haskell

Dealing with Dates and Times (5/365)

In the past, I’ve had to deal with reading, writing, and performing arithmetic on dates and times in Haskell and the experience is not a pleasant one. Actually, I’ve had to do this in PHP and Erlang and the experience … Continue reading

Posted in Haskell | Tagged , | Leave a comment

Haskell Abstractions At Work (Part II – An Interlude)

View literate file on Github The boss wants more So the boss comes back and says, “Naren, this is great but I don’t want to write code to specify my schedule”. He scribbles some notes on the whiteboard to illustrate … Continue reading

Posted in Haskell | Tagged , , , | Leave a comment

Haskell Abstractions At Work (Part I)

View literate file on Github Recently, while constructing a domain-specific language (DSL), I had to solve a problem analogous to the following. You are given a company with boss and employees represented by their free-time schedules. For instance, is an … Continue reading

Posted in Haskell | Tagged , , | Leave a comment

Short-circuiting

View literate file on Github Short-circuiting in imperative languages is a doddle – just put a break; to get out of a loop. Having said that, things are trickier when you want to break out into various levels within nested … Continue reading

Posted in Haskell | Tagged , | Leave a comment

Young Tableau: A Monoid (Part III)

View literate file on Github > import YT Last time, we defined an operation that allowed us to grow a young tableau by a single number. It turns out that we can use this to give a monoid structure to … Continue reading

Posted in Combinatorics, Haskell | Tagged , | Leave a comment

Performance: Looping

View source file on Github Before I finish off the Hungarian algorithm, I want to settle (nominally) the matter of performance with respect to array/vector based number-crunching in Haskell. I never sat down to consider this matter systematically and now … Continue reading

Posted in Haskell | Tagged , | Leave a comment

Young Tableau: Row-insertion (Part II)

View literate file on Github > import Control.Lens > import Control.Monad > import Control.Monad.State > import Data.List > import Test.QuickCheck Having defined a Young Tableau, let’s consider one of the ways to construct it. How can you go about adding … Continue reading

Posted in Combinatorics, Haskell | Tagged , | Leave a comment

Hungarian Algorithm (Part I): Minimal covering of zeros

View source file on Github > module Main where > import Control.Lens hiding (assign) > import Control.Monad > import Data.List > import Data.Ord (comparing) > import Test.QuickCheck hiding (sample) > import qualified Data.IntSet as I I will resist posts on … Continue reading

Posted in Algorithm, Combinatorics, Haskell | Tagged | Leave a comment

Choices: Command Line Parsers

View literate file on Github Like everything in Haskell, parsing command line arguments comes with its own marketplace. > {-# LANGUAGE DeriveDataTypeable #-} > > module Main where > import Prelude hiding (lines) > import Options.Applicative > import System.Environment (getArgs) … Continue reading

Posted in Choices, Haskell | Tagged | 3 Comments

Quickie: Generating the powerset

View literate file on Github > import Control.Monad The traditional way to generate the powerset of a list of elements is the following > powerset :: [a] -> [[a]] > powerset (x:xs) = map (x:) (powerset xs) ++ powerset xs … Continue reading

Posted in Haskell | Tagged , , | Leave a comment