packages feed

miso 0.2.0.0 → 0.2.1.0

raw patch · 3 files changed

+90/−15 lines, 3 files

Files

README.md view
@@ -30,8 +30,14 @@   </a> </p> -**Miso** is a small "[isomorphic](http://nerds.airbnb.com/isomorphic-javascript-future-web-apps/)" [Haskell](https://www.haskell.org/) front-end framework featuring a virtual-dom, diffing / patching algorithm, event delegation, event batching, SVG, Server-sent events, Websockets, type-safe [servant](https://haskell-servant.github.io/)-style routing and an extensible Subscription-based subsystem. Inspired by [Elm](http://elm-lang.org/), [Redux](http://redux.js.org/) and [Bobril](http://github.com/bobris/bobril). `IO` and other effects (like `XHR`) can be introduced into the system via the `Effect` data type. Miso makes heavy use of the [GHCJS](https://github.com/ghcjs/ghcjs) FFI and therefore has minimal dependencies.+**Miso** is a small "[isomorphic](http://nerds.airbnb.com/isomorphic-javascript-future-web-apps/)" [Haskell](https://www.haskell.org/) front-end framework featuring a virtual-dom, diffing / patching algorithm, event delegation, event batching, SVG, Server-sent events, Websockets, type-safe [servant](https://haskell-servant.github.io/)-style routing and an extensible Subscription-based subsystem. Inspired by [Elm](http://elm-lang.org/), [Redux](http://redux.js.org/) and [Bobril](http://github.com/bobris/bobril). **Miso** is pure by default, but side effects (like `XHR`) can be introduced into the system via the `Effect` data type. **Miso** makes heavy use of the [GHCJS](https://github.com/ghcjs/ghcjs) FFI and therefore has minimal dependencies. +## Table of Contents+- [Examples](#examples)+- [Haddocks](#haddocks)+- [Sample Application](#sample-application)+- [Building examples](#building-examples)+ ## Examples   - TodoMVC     - [Link](https://todo-mvc.haskell-miso.org/)@@ -55,38 +61,86 @@   - [GHCJS](https://haddocks.haskell-miso.org/)   - [GHC](http://hackage.haskell.org/package/miso) -## Getting Started+## Sample application ```haskell+-- | Haskell language pragma {-# LANGUAGE RecordWildCards #-} +-- | Haskell module declaration module Main where +-- | Miso framework import import Miso +-- | Type synonym for an application model type Model = Int +-- | Sum type for application events+data Action+  = AddOne+  | SubtractOne+  deriving (Show, Eq)++-- | Entry point for a miso application main :: IO () main = startApp App {..}   where-    model  = 0-    update = updateModel-    view   = viewModel-    events = defaultEvents-    subs   = []+    model  = 0   		-- initial model+    update = updateModel	-- update function+    view   = viewModel		-- view function+    events = defaultEvents	-- default delegated events+    subs   = []			-- empty subscription list +-- | Updates model, optionally introduces side effects updateModel :: Action -> Model -> Effect Model Action updateModel AddOne m = noEff (m + 1) updateModel SubtractOne m = noEff (m - 1) -data Action-  = AddOne-  | SubtractOne-  deriving (Show, Eq)-+-- | Constructs a virtual DOM from a model viewModel :: Model -> View Action viewModel x = div_ [] [    button_ [ onClick AddOne ] [ text "+" ]  , text (show x)  , button_ [ onClick SubtractOne ] [ text "-" ]  ]- ```+```++## Building examples++The easiest way to build the examples is with the [`nix`](https://nixos.org/nix/) package manager+```+git clone https://github.com/dmjio/miso && cd miso && nix-build+```++This will build all examples and documentation into a folder named `result`+```+➜  miso git:(master) ✗ tree result -d+result+|-- doc+|   |-- x86_64-osx-ghc-8.0.2+|   |   `-- miso-0.2.0.0+|   |       `-- html+|   |           `-- src+|   `-- x86_64-osx-ghcjs-0.2.0-ghc7_10_3+|       `-- miso-0.2.0.0+|           `-- html+|               `-- src+|-- examples+|   |-- mario.jsexe+|   |   `-- imgs+|   |       |-- jump+|   |       |-- stand+|   |       `-- walk+|   |-- router.jsexe+|   |-- simple.jsexe+|   |-- tests.jsexe+|   |-- todo-mvc.jsexe+|   `-- websocket.jsexe+```++To see examples, we recommend hosting them with a webserver++```+cd result/examples/todo-mvc.jsexe && python -m SimpleHTTPServer+Serving HTTP on 0.0.0.0 port 8000 ...+```
+ ghc-src/Miso.hs view
@@ -0,0 +1,21 @@+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE LambdaCase          #-}+{-# LANGUAGE RecordWildCards     #-}+{-# LANGUAGE DataKinds           #-}+{-# LANGUAGE KindSignatures      #-}+-----------------------------------------------------------------------------+-- |+-- Module      :  Miso+-- Copyright   :  (C) 2016-2017 David M. Johnson+-- License     :  BSD3-style (see the file LICENSE)+-- Maintainer  :  David M. Johnson <djohnson.m@gmail.com>+-- Stability   :  experimental+-- Portability :  non-portable+----------------------------------------------------------------------------+module Miso+  ( module Miso.Event+  , module Miso.Html+  ) where++import           Miso.Event+import           Miso.Html
miso.cabal view
@@ -1,5 +1,5 @@ name:                miso-version:             0.2.0.0+version:             0.2.1.0 category:            Web, Miso, Data Structures license:             BSD3 license-file:        LICENSE@@ -139,6 +139,7 @@   default-language:     Haskell2010   exposed-modules:+    Miso     Miso.Html     Miso.Html.Element     Miso.Html.Event@@ -185,7 +186,6 @@       jsbits/isomorphic.js       jsbits/util.js     exposed-modules:-      Miso       Miso.Effect       Miso.Effect.Storage       Miso.Effect.XHR