Possibly what we need is a pragma to mark functions partial and a warning
flag that warns on usage of functions that have been marked partial.
I had this in mind too, but that is very heavy solution. I’d rather start with making hlint warnings?
foo :: Maybe Int -> Int
foo x = if isJust x then fromJust x else 0
bar :: Maybe Int -> Int
bar x = 1 + fromJust x
It warns about `foo` nonsense. It could propose to change `bar` part into `fromMaybe (error “I’know what I’m doing”) x` ?
- Oleg