Match function type using typeclasses