Slide 1

Slide 1 text

todo-example Showcase of a lightweight web application written in Haskell J¨ urgen Cito Vienna Univeristy of Technology, Austria New York Haskell User Group October 2nd, 2013 1 / 6

Slide 2

Slide 2 text

Intro – todo-example • What is it? “A simple todo list server with a REST API, written in Haskell using Welshy and TX, with a simple UI displaying the interaction with the API” • Resulted from a project in ’Industrial Haskell’ at Vienna UT in a group with Michael Schr¨ oder and Harald Steinlechner (held by hvr1 - lecture notes avaible2) 1https://github.com/hvr 2http://hvr.github.io/VU183653/2013S/ 2 / 6

Slide 3

Slide 3 text

Welshy • REST DSL based on Scotty3 • Goal: Easier error handling and convenience functions • halt the current action at any point unless (length > 0) (halt $ status badRequest400) • built-in error handling for queryParam, jsonParam, bearerAuth • Action monad is an Alternative instance offset <- queryParam "offset" <|> return 0 3http://hackage.haskell.org/package/scotty 3 / 6

Slide 4

Slide 4 text

TX • Persistent transactions on top of STM • Similar to acid-state • Very simple (∼100 lines of code) class SafeCopy (Update d) => Persistable d where data Update d replay :: Update d -> TX d () ... data MyDB = MyDB { posts :: TVar [String] } instance Persistable MyDB where data Update MyDB = CreatePost String | ModifyPost Int String replay (CreatePost p) = void $ createPost p replay (ModifyPost n p) = modifyPost n p 4 / 6

Slide 5

Slide 5 text

Future Work • Get rid of JS4 – GHCJS? • Long polling list <- getList listId check $ now < listUpdatedAt list return list • Improve Welshy, TX 4http://www.haskell.org/haskellwiki/The_JavaScript_Problem 5 / 6

Slide 6

Slide 6 text

Where? Where to find this – Hackage/Github: • todo-example: https://github.com/mcschroeder/todo-example • Welshy: http://hackage.haskell.org/package/welshy • TX: http://hackage.haskell.org/package/tx Who to contact: • Michael Schr¨ oder (twitter: @schrototo) • Harald Steinlechner (github: haraldsteinlechner) • J¨ urgen Cito (twitter: @citostyle) 6 / 6