[Haskell] ANN: ivy-web 0.1
James Deng
cnjamesdeng at gmail.com
Mon Sep 19 12:34:05 CEST 2011
Dear all,
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)
$(defineIsomorphisms ''Blog)
instance Handler Blog where
get b@(Blog y m d) _ = do
t <- liftIO getClockTime
return $ responseHtml $ trans' "blog" ++ show b ++ show t
rBlog = blog <$> text "/blog/" *> int <-> int <-> int
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.
*
Easy i18n
Wraps around i18n library.
* TODO: Auth system
Port from snap-auth.
* TODO: Modular app system like Django
The current route system support modular routes very well. Need
works in modular config and data files like static template files.
* 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.
Hackage: http://hackage.haskell.org/package/ivy-web
Repo: https://github.com/lilac/ivy-web/
For the example code listed above, please refer to
https://github.com/lilac/ivy-example/
--
*James Deng*
department of computer science
school of information science & technology
Sun-yat-sen University, Guangzhou, China
http://cnjdeng.appspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell/attachments/20110919/94cbb38e/attachment.htm>
More information about the Haskell
mailing list