Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by chi for How to deal with a list of 'Maybe [values]' in Haskell?

There might be some more advanced library helpers, but I think you should first learn how to handle Maybes in the most basic (and general) way: use pattern matching.

case lookup situacio edges of   Nothing   -> [] -- not found, how do you want to handle this case?   Just locs -> map describePath locs

Oftentimes, one wants instead to rewrap the result in another Maybe, e.g.:

case lookup situacio edges of   Nothing   -> Nothing -- not found   Just locs -> Just (map describePath locs)

and in such case, we can use a library helper function to shorten the code:

map describePath <$> lookup situacio edges

Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>