Typed DSLs for sorting