Typeclass for builders of linear data structures