swarm-game / swarm

Resource gathering + programming game
Other
833 stars 52 forks source link

Ban (or restrict) partial functions with hlint #1494

Open kostmo opened 1 year ago

kostmo commented 1 year ago

Ideally we don't want any instances of error in the codebase (https://github.com/swarm-game/swarm/pull/1484#discussion_r1315211065). For similar reasons, we should restrict use of partial functions like (!!), fromJust, and head to a vetted subset of modules. hlint can whitelist where certain functions may be used.

byorgey commented 12 months ago

It looks like we don't have any uses of fromJust, so we could just add that to the hlint config.

xsebek commented 12 months ago

There may be other more obscure functions - for example in tests, I use the sneaky (^?!). 🙂

byorgey commented 12 months ago

I'm not as concerned about tests, since those don't directly affect users if they crash. But yes, we should disallow (^?!) and its ilk.