From: Jaseem Abid Date: Mon, 30 Mar 2015 16:30:13 +0000 (+0530) Subject: Minor refactor maybeBstrToString X-Git-Url: https://git.rkrishnan.org/pf/content/en/service/frontends/CLI.txt?a=commitdiff_plain;h=e1de92c59140251ccb2a094e40cf5cbf04d259e6;p=functorrent.git Minor refactor maybeBstrToString Makes the function total. Also, this looks a lot like fmap! --- diff --git a/src/FuncTorrent/Metainfo.hs b/src/FuncTorrent/Metainfo.hs index 216fd24..d6f2cf7 100644 --- a/src/FuncTorrent/Metainfo.hs +++ b/src/FuncTorrent/Metainfo.hs @@ -49,9 +49,8 @@ mkInfo (Bdict m) = let (Bint pieceLength') = m ! "piece length" mkInfo _ = Nothing maybeBstrToString :: Maybe BVal -> Maybe String -maybeBstrToString Nothing = Nothing -maybeBstrToString (Just s) = let (Bstr bs) = s - in Just (unpack bs) +maybeBstrToString (Just (Bstr bs)) = Just $ unpack bs +maybeBstrToString _ = Nothing mkMetaInfo :: BVal -> Maybe Metainfo mkMetaInfo (Bdict m) = let (Just info') = mkInfo $ m ! "info"