fsharp / fslang-suggestions

The place to make suggestions, discuss and vote on F# language and core library features
344 stars 21 forks source link

`defer-errors-to-runtime` mode for gradual "unbreaking my code" in large refactor #1340

Open smoothdeveloper opened 11 months ago

smoothdeveloper commented 11 months ago

I propose we enable a defer-errors-to-runtime[^1] feature for using fsharp compilation output even when there are type checking errors.

The F# way right now is to increase developer proficiency so any refactor is less than few minutes and always known to succeed, before getting feedback from the already running bits for the developer, this is great for making any F# developer a true jedi.

This is not great though when you tackle refactor and would like to at least try a bit of it for a specific focus area, without resorting to really crude things that can be done depending on the codebase (excluding many things, putting some #if in many places, etc.).

I think this is what the proponents of gradual typing peddle when they want to make our community of "like to rely on typechecker by default" (in same sense of "immutable by default", etc.) feel culprit of being in a type checker astronaut architect ivory tower, but I think it is possible to have the best of both, but in the F# way (not "on by default", only recommended if "you know what you are doing right?").

I remember hearing Gilad Bracha on topic of gradual typing, many years back, in context of vending dart, here is one such video: https://youtu.be/OGrXxGD-pZg?t=1416

Pros

Cons

Extra information

Estimated cost (XS, S, M, L, XL, XXL): XXL most likely, maybe less if @dsyme wants it badly?

Affidavit (please submit!)

Please tick these items by placing a cross in the box:

Please tick all that apply:

For Readers

Please express your disgust for this idea with 👎, and argue that "F# is not for this" to your heart content in the textbox below this text.

[^1] credit to @drvink for pointing to haskell support for this, how it is done in "Equality proofs and deferred type errors A compiler pearl" paper

pbiggar commented 11 months ago

I believe this is a good idea. Developers love Gradual Dynamic Typing, which has a lot of disadvantages, but allows running broken code as a major advantage. One of the weakest parts of statically typed programming languages is that it must type check before we can test it, and this Gradual Static Typing can resolve it.

Note that both Darklang and Roc (new functional programming languages that are exceptionally similar to F#) both support this as headline-ish features.