git.iko.soy/typeable/http-api-data
on master help sign in
The instance for Maybe can now parse the string "Nothing".

"Nothing" -> Nothing :: Maybe a "Just Nothing" -> Just "Nothing" :: Maybe Text Type `Maybe (Maybe a)` can not be parsed in the route file but it is safe to assume that : "Just Nothing" -> Just Nothing :: Maybe (Maybe a)" and that "Just Just Nothing" -> Just (Just "Nothing") :: Maybe (Maybe Text)

commit54247f9c1a278e7fbe1e66915091934a4fa458f8 authorMomemtumMori <admin@momemtummori.info> dateWed 9 Jul 2014, 04:50 (12 years ago) parent647a20b
1 file changed+6−3
Web/PathPieces.hs+6−3
Web/PathPieces.hs+6−3
@@ -83,9 +83,12 @@ instance PathMultiPiece [L.Text] where
8383 toPathMultiPiece = map $ S.concat . L.toChunks
8484
8585instance (PathPiece a) => PathPiece (Maybe a) where
86− fromPathPiece s = case s of
87− "Nothing" -> Just Nothing
88− _ -> Just $ fromPathPiece s
86+ fromPathPiece s = if isPrefixOf "Just " s
87+ then Just $ fromPathPiece $ fromJust $ stripPrefix "Just " s
88+ else
89+ if s == "Nothing"
90+ then Just Nothing
91+ else Nothing
8992 toPathPiece m = case m of
9093 Just s -> toPathPiece s
9194 _ -> "Nothing"