I have been writing quickly some code in Haskell, and used a dangerous non-total function, namely fromJust
(where I expect a value from input). I'm going to think later what kind of error-handling style I want to use.
Can GHC help me make sure that I have got rid of all uses of dangerous non-total functions (like fromJust
or head
, which could crash) , give me warnings where they are.
GHC can warn about definitions with partial patterns with -fwarn-incomplete-patterns
(though does not warn about uses of values that include incomplete patterns). Additionally, Neil Mitchell's catch attempts a slightly more detailed analysis to identify safe and unsafe invocations of partial functions. (Though of course that's an undecidable problem in general, so it won't always be right!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With