I guess it depends on whether you'd like to see Maybe as a data type or a monad,
'Just' is constructor whereas 'return' is a function defined in Monad typeclass.
and 'Maybe' is an instance of Monad, with definition of 'return' as 'Just'.
data Maybe a = Nothing | Just a
instance Monad Maybe where
return = Just
fail = Nothing
Nothing >>= f = Nothing
(Just x) >>= f = f x
So it's not more generic in this particular case, but I do agree on using return instead of constructor directly will provide more monadic style.
Henrik Larsson於 2015年1月13日星期二 UTC+1上午10時22分01秒寫道: