Haskel implementation.