haskell - Minimum of Two Maybes -


i want minimum of 2 maybe values, or if 1 nothing non-nothing one, or return nothing if both inputs nothing. can write simple function this, suspect there way without writing custom function. sorry, if petty question, there simpler way using custom function?

minmaybe :: ord => maybe -> maybe -> maybe minmaybe nothing b = b minmaybe nothing = minmaybe (just a) (just b) = $ min b 

you cannot use applicative, or monad instance this, since nothing in contexts have total result being nothing. being said, term "simpler" highly opinionated, , function fine is.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -