Skip to content

Instantly share code, notes, and snippets.

@mmynsted
Created January 23, 2021 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmynsted/b0e512c4f5cf93992e790bc997b2cc52 to your computer and use it in GitHub Desktop.
Save mmynsted/b0e512c4f5cf93992e790bc997b2cc52 to your computer and use it in GitHub Desktop.
getReviewStars :: [String] -> String
+ getReviewStars args = fromMaybe "" $ f args
+ where
+ f = fmap (T.unpack . reviewStars) . (readMaybe <=< listToMaybe) :: [String] -> Maybe String
@mmynsted
Copy link
Author

mmynsted commented Jan 23, 2021

The following is better

getReviewStars :: [String] -> String
 getReviewStars args = fromMaybe "" $ f args
   where
     f :: [String] -> Maybe String
     f = fmap (T.unpack . reviewStars) . (readMaybe <=< listToMaybe) 

@mmynsted
Copy link
Author

Even better

getReviewStars :: [String] -> String
 getReviewStars args = maybe "" (T.unpack . reviewStars) ((readMaybe <=< listToMaybe) args)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment