The _type flag is wasteful and makes for trivially more expensive construction and destruction. It’d be more efficient—and I would argue more ergonomic—to split the Temp type into two types, TempFile and TempDir. (I’m not going to suggest phantom types, because they’re more complex for no gain that is evident to me.)
The
_typeflag is wasteful and makes for trivially more expensive construction and destruction. It’d be more efficient—and I would argue more ergonomic—to split theTemptype into two types,TempFileandTempDir. (I’m not going to suggest phantom types, because they’re more complex for no gain that is evident to me.)