ShapeCoder: Discovering Abstractions for Visual Programs from Unstructured Primitives