Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Socket.io for Haskell folks

Ting-Yen Lai
December 08, 2013

Socket.io for Haskell folks

Ting-Yen Lai

December 08, 2013
Tweet

More Decks by Ting-Yen Lai

Other Decks in Programming

Transcript

  1. Socket.IO for Haskell Folks

  2. None
  3. None
  4. None
  5. Real-time Applications

  6. Regular HTTP

  7. Polling

  8. Long-Polling

  9. EventSource

  10. WebSocket

  11. WebSocket

  12. “TCP for the web”

  13. PROS Bi-directional + Full-duplex ! Lower overhead ! Port 80

  14. CONS Not widely supported ! Still a draft*

  15. Socket.IO

  16. asdf

  17. “The cross-browser cross-device WebSocket”

  18. Browser Support IE 5.5+ Safari 2+ Google Chrome 4+ Firefox

    3+ Opera 10.61+
  19. Transport Support WebSocket Flash Socket AJAX long polling AJAX multipart

    Forever iframe JSONP Polling
  20. socket.emit(‘news’, ‘hey!’); ! ! ! Server

  21. socket.on(‘news’, function (data) { console.log(data); // hey! }); ! Client

  22. socket.emit(‘news’, ‘hey!’); ! socket.on(‘ping’, function () { socket.emit(‘pong’); }); Server

  23. socket.on(‘news’, function (data) { console.log(data); // hey! }); ! socket.emit(‘ping’);

    Client
  24. Originated from Node.js

  25. Now also available in many other languages Erlang Java Lua

    Python Perl Go C++ C Objective-C Haxe Ruby PHP
  26. Except for Haskell

  27. None
  28. socketio-0.1.0

  29. None
  30. socket.emit(‘news’, ‘hey!’); ! socket.on(‘ping’, function () { socket.emit(‘pong’); });

  31. emit “news” [“hey!”] ! on “ping” $ emit “pong” []

  32. Transport Support WebSocket (80%) Flash Socket AJAX long polling AJAX

    multipart Forever iframe JSONP Polling
  33. Difficulties

  34. Transport Support ಠ~ಠ

  35. Transport Support WebSocket Flash Socket AJAX long polling AJAX multipart

    Forever iframe JSONP Polling
  36. Transport Support WebSocket Flash Socket AJAX long polling AJAX multipart

    Forever iframe JSONP Polling
  37. “Premature optimization is the root of all evil”

  38. Monad Transformers ಠ~ಠ

  39. None
  40. None
  41. ! KEEP CALM AND JUST USE IT

  42. None
  43. Iteratee I/O ಠ~ಠ

  44. None
  45. None
  46. None
  47. None
  48. String/Text/ByteString ಠ~ಠ

  49. None
  50. {-# LANGUAGE OverloadedStrings #-}

  51. Open Source Community ಠ~ಠ

  52. None
  53. None
  54. Originated from Node.js

  55. Cabal Hell ಠ~ಠ

  56. > cabal uninstall cabal: unrecognised command: uninstall (try --help)

  57. None
  58. cabal-dev?

  59. LIVE DEMO

  60. None
  61. http://banacorn.org:3000

  62. None
  63. TODO

  64. cabal-dev?

  65. banacorn/socket.io-haskell ! ! ! ALL CONTRIBUTIONS ARE WELCOME!

  66. THANKS! Questions?