Repurpose Sign Example for Maybe Type in Documentation #120
Labels
effort: 1
Takes roughly 1 hour (w/ docs+testing)
good first issue
Good for newcomers
type: docs
Improvements or additions to documentation
work: obvious
Straightforward tasks with known solutions; follow best practices
The current example function,
getSign
, determines if a number is positive, negative, or zero by returning one of three values:Positive
,Negative
, orZero
. However, this classification can be debated, as zero is often considered to have no sign at all. Given this interpretation, the example could better demonstrate the use of theMaybe
type.Proposed Change:
Modify the existing
getSign
function to return aMaybe Sign
type, where:Just Positive
indicates a positive number.Just Negative
indicates a negative number.Nothing
represents zero, reflecting that zero has no sign.Updated Code Example:
Benefits:
Maybe
, making it easier to understand when and why to use this type in Haskell.Impact on Documentation:
This change would update the
Sign
example in the documentation to provide a clearer and more nuanced understanding ofMaybe
. It would serve as a concrete illustration of how to handle values that might not exist, improving the educational value of the example.Additional Context:
This suggestion is based on the reasoning that zero lacks a positive or negative sign, making
Maybe
a more suitable approach for this specific use case.The text was updated successfully, but these errors were encountered: