re-implemenation of shapeme in Haskell