I wrote this code to append Maybe
's:
ghci> (:) <$> Just 5 <*> ((:) <$> Just 100 <*> Just [])
Just [5,100]
Similarly:
ghci> (:) <$> Just 5 <*> ( (:) <$> Just 10 <*> ((:) <$> Just 100 <*> Just []) )
Just [5,10,100]
Is this code idiomatic? Perhaps there's a more concise way to append a bunch of Maybe
's together?
Just [5,10,100]
? \$\endgroup\$<*>
. No real purpose other than curiosity. \$\endgroup\$sequence
andconcatMap maybeToList
:sequence [Just 1, Nothing, Just 2]
isNothing
; whereasconcatMap maybeToList [Just 1, Nothing, Just 2]
is[1, 2]
. \$\endgroup\$