paulyoung / mvc-todo

A haskell implementation of todoMVC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Haskell TodoMVC Example

Haskell is a strongly-typed, lazily-evaluated, functional programming language.

This example demonstrates an idiomatic haskell approach to the TodoMVC problem domain involving:

  • compilation of haskell to javascript using ghcjs.
  • The specification of a Model representing the problem domain, consisting of
    • specification of Abstract Data Types (ADTs) for inputs, state and outputs.
    • an algebra between state and actions, utilising the lens library.
  • Use of the mvc library for specification, asynchronicity and separation of model, view and controllers.
  • The creation of Views that consume model outputs, by creating Dom effects.
  • The creation of Controllers that produce model inputs, by listening for Dom events.

build/develop

  • install ghcjs
  • cabal configure --enable-tests && cabal build && cabal test
  • point browser at index.html (or serve file)

ghci

ghcjs doesn't currently support interactive usage such as ghci. However, GHCJS.Extended includes dummy definitions to enable normal compilation by ghc and thus ability to use ghci for type checking and such. Just:

  • edit cabal.configure to remove compiler: ghcjs
  • run cabal configure --flags=no-ghcjs && cabal build

(Idea ripped from ghcjs-react)

About

A haskell implementation of todoMVC

License:MIT License


Languages

Language:Haskell 90.3%Language:HTML 8.4%Language:JavaScript 1.3%