ANN: ivy-web 0.1
2011-09-19 10:34:05 GMT
I am pleased to announce the first release of ivy-web after learning haskell for a year.
Ivy-web is a lightweight web framework, with type safe routes, based on invertible-syntax, and i18n support, influenced by Django, Snap and Yesod.
The features of this web framework:
Type safe routes, specify url-handler mapping in one place. For example, we want a url mapping for blog as "/blog/year-month-day" to Handler Int Int Int, where year, month and day are integers. We can declare as follows:
data Blog = Blog Int Int Int deriving (Show, Eq, Typeable)rBlog = blog <$> text "/blog/" *> int <-> int <-> int
instance Handler Blog whereget b <at> (Blog y m d) _ = do
t <- liftIO getClockTime
return $ responseHtml $ trans' "blog" ++ show b ++ show t
We can reverse this mapping from handler value automatically, thus don't need to construct url string manually in code, avoiding url errors.
ghci>url (Blog 2011 9 19) == "/blog/2011-9-19"
Simple yet elegant handler via type class.
class Handler a where
get, post, put, delete, handle :: a -> Application
handle a req = case requestMethod req of
m | m == methodGet -> get a req
| m == methodPost -> post a req
| m == methodPut -> put a req
| m == methodDelete -> delete a req
otherwise -> unimplemented req
Flexible template system, utilize exsisting libraries such as Blaze-Html and Hastache.
- TODO: Auth system
Port from snap-auth.
- TODO: Modular app system like Django
- TODO: Persistent library
Improving the DSH library is my current preference.
The principle of this library is KISS, and "don't reinvent the wheel" by reusing existing state-of-the-art libraries.
For the example code listed above, please refer to https://github.com/lilac/ivy-example/
department of computer science
school of information science & technology
Sun-yat-sen University, Guangzhou, China
_______________________________________________ Haskell mailing list Haskell <at> haskell.org http://www.haskell.org/mailman/listinfo/haskell