git.iko.soy/typeable/http-api-data
on master help sign in
Added instance for Maybe.
commit1aa1d7822869dfa63b717aa857eda54c9a264d8c authorMomemtumMori <admin@momemtummori.info> dateSun 22 Jun 2014, 12:08 (12 years ago) parent9de36e9
1 file changed+8
Web/PathPieces.hs+8
Web/PathPieces.hs+8
@@ -82,6 +82,14 @@ instance PathMultiPiece [L.Text] where
8282 fromPathMultiPiece = Just . map (L.fromChunks . return)
8383 toPathMultiPiece = map $ S.concat . L.toChunks
8484
85+instance (PathPiece a) => PathPiece (Maybe a) where
86+ fromPathPiece s = case s of
87+ "Nothing" -> Just Nothing
88+ _ -> Just $ fromPathPiece s
89+ toPathPiece m = case m of
90+ Just s -> toPathPiece s
91+ _ -> "Nothing"
92+
8593{-# DEPRECATED toSinglePiece "Use toPathPiece instead of toSinglePiece" #-}
8694toSinglePiece :: PathPiece p => p -> S.Text
8795toSinglePiece = toPathPiece