git.iko.soy/typeable/http-api-data
on master help sign in
Streamlined `fromPathPiece` implementation.
commit54b0c624946231a03a9d41780880e1ebed44b0bc authorMomemtumMori <admin@momemtummori.info> dateWed 9 Jul 2014, 11:38 (12 years ago) parent1cd599e
1 file changed+5−6
Web/PathPieces.hs+5−6
Web/PathPieces.hs+5−6
@@ -84,12 +84,11 @@ instance PathMultiPiece [L.Text] where
8484 toPathMultiPiece = map $ S.concat . L.toChunks
8585
8686instance (PathPiece a) => PathPiece (Maybe a) where
87− fromPathPiece s = if S.isPrefixOf "Just " s
88− then Just $ fromPathPiece $ fromJust $ S.stripPrefix "Just " s
89− else
90− if s == "Nothing"
91− then Just Nothing
92− else Nothing
87+ fromPathPiece s = case S.stripPrefix "Just " s of
88+ Just r -> Just $ fromPathPiece r
89+ _ -> case s of
90+ "Nothing" -> Just Nothing
91+ _ -> Nothing
9392 toPathPiece m = case m of
9493 Just s -> "Just " `S.append` toPathPiece s
9594 _ -> "Nothing"