I use this similarity to create parsec-like combinators that use the formlet monad in MFlow (the View monad) to parse the web service parameters and to generate the output.
This service below implements a service that sum or multiply two Int-egers.
main = runNavigation "apiparser" . step . asks $ do rest "sum" ; disp $ (+) <$> wint "t1" <*> wint "t2" <|> do rest "prod" ; disp $ (*) <$> wint "t1" <*> wint "t2" <?> do -- blaze Html h1 << "ERROR. API usage:" h3 << "http://server/api/sum?t1=[Int]&t2=[Int]" h3 << "http://server/api/prod?t1=[Int]&t2=[Int]" where asks w= ask $ w >> stopSee a more complete explanation and working examples here:
http://mflowdemo.herokuapp.com/noscript/wiki/webservicesBy the way:The blogger editing system is the ugliest and unfriendly thing invented by mankind. It is not worth being a Google product. The feedback link does not work.
No comments:
Post a Comment