bcpeinhardt / simplifile

Simple file operations for Gleam that work on all targets (Erlang/Node/Deno)
71 stars 10 forks source link

add pokayokefile #21

Closed erikareads closed 7 months ago

erikareads commented 7 months ago

Creates pokayokefile an alternate API for simplifile that uses tagged constructors to ensure statically checked arguments.

The constructors are public, so it's easy to unpack the types if needed. The types are only enforced on function arguments not on return types, so that the caller can decide how they would like to treat returned values.

erikareads commented 7 months ago

I copied the entire public API of simplifile, which does raise two deprecation errors from using the deprecated simplifile functions. It may be worth leaving those out here.

bcpeinhardt commented 7 months ago

After thinking about this, I think I'm going to stick to the single API for now. Here are my concerns:

  1. Maintaining two copies of the same API can become a maintenance burden.
  2. If downstream packages expose APIs with (File/Src/Dest)Path in their signatures, then they force users into using path types, which most gleamlins are against.
  3. Most functions don't become any clearer with the wrapper types, and ambiguity can currently be avoided by simply using the provided labels. I'm not convinced it's worth the increased boilerplate.

I really appreciate you taking the time to contribute, and hope you continue to do so :)