I have scoured the internet for an actual explanation of what this keyword does. Every Haskell tutorial that I have looked at just starts using it randomly and never explain
Function if (cond :: Bool) then (ifTrue :: a) else (ifFalse :: a) must have the same type of ifTrue and ifFalse.
if (cond :: Bool) then (ifTrue :: a) else (ifFalse :: a)
ifTrue
ifFalse
So, when we write then Nothing, we must use Maybe a type in else f
then Nothing
Maybe a
else f
if balance < reserve then (Nothing :: Maybe nb) -- same type else (Just newBalance :: Maybe nb) -- same type