use typecalss and type families to refactor code. for interfacing haskell-src later