Permalink
Browse files

Remove all the nesting/ examples

This was leading people astray. Need to have examples that let folks
work up to these concepts so they do not overuse them in inappropriate
situations.
  • Loading branch information...
evancz committed Aug 30, 2016
1 parent 5f6dd90 commit 82243d2d8a4269547ee37276fd98c851a14d7d38
Showing with 0 additions and 589 deletions.
  1. +0 −67 nesting/1-counter-pair.elm
  2. +0 −92 nesting/2-counter-list.elm
  3. +0 −98 nesting/3-gif-pair.elm
  4. +0 −160 nesting/4-gif-list.elm
  5. +0 −60 nesting/Counter.elm
  6. +0 −112 nesting/Gif.elm
View
@@ -1,67 +0,0 @@
-import Counter
-import Html exposing (Html, button, div, text)
-import Html.App as App
-import Html.Events exposing (onClick)
-
-
-
-main =
- App.beginnerProgram
- { model = init 0 0
- , update = update
- , view = view
- }
-
-
-
--- MODEL
-
-
-type alias Model =
- { topCounter : Counter.Model
- , bottomCounter : Counter.Model
- }
-
-
-init : Int -> Int -> Model
-init top bottom =
- { topCounter = Counter.init top
- , bottomCounter = Counter.init bottom
- }
-
-
-
--- UPDATE
-
-
-type Msg
- = Reset
- | Top Counter.Msg
- | Bottom Counter.Msg
-
-
-update : Msg -> Model -> Model
-update message model =
- case message of
- Reset ->
- init 0 0
-
- Top msg ->
- { model | topCounter = Counter.update msg model.topCounter }
-
- Bottom msg ->
- { model | bottomCounter = Counter.update msg model.bottomCounter }
-
-
-
--- VIEW
-
-
-view : Model -> Html Msg
-view model =
- div
- []
- [ App.map Top (Counter.view model.topCounter)
- , App.map Bottom (Counter.view model.bottomCounter)
- , button [ onClick Reset ] [ text "RESET" ]
- ]
View
@@ -1,92 +0,0 @@
-import Counter
-import Html exposing (..)
-import Html.App as App
-import Html.Attributes exposing (..)
-import Html.Events exposing (..)
-
-
-
-main =
- App.beginnerProgram
- { model = init
- , update = update
- , view = view
- }
-
-
-
--- MODEL
-
-
-type alias Model =
- { counters : List IndexedCounter
- , uid : Int
- }
-
-
-type alias IndexedCounter =
- { id : Int
- , model : Counter.Model
- }
-
-
-init : Model
-init =
- { counters = []
- , uid = 0
- }
-
-
-
--- UPDATE
-
-
-type Msg
- = Insert
- | Remove
- | Modify Int Counter.Msg
-
-
-update : Msg -> Model -> Model
-update message ({counters, uid} as model) =
- case message of
- Insert ->
- { model
- | counters = counters ++ [ IndexedCounter uid (Counter.init 0) ]
- , uid = uid + 1
- }
-
- Remove ->
- { model | counters = List.drop 1 counters }
-
- Modify id msg ->
- { model | counters = List.map (updateHelp id msg) counters }
-
-
-updateHelp : Int -> Counter.Msg -> IndexedCounter -> IndexedCounter
-updateHelp targetId msg {id, model} =
- IndexedCounter id (if targetId == id then Counter.update msg model else model)
-
-
-
--- VIEW
-
-
-view : Model -> Html Msg
-view model =
- let
- remove =
- button [ onClick Remove ] [ text "Remove" ]
-
- insert =
- button [ onClick Insert ] [ text "Add" ]
-
- counters =
- List.map viewIndexedCounter model.counters
- in
- div [] ([remove, insert] ++ counters)
-
-
-viewIndexedCounter : IndexedCounter -> Html Msg
-viewIndexedCounter {id, model} =
- App.map (Modify id) (Counter.view model)
View
@@ -1,98 +0,0 @@
-import Html exposing (..)
-import Html.App as App
-import Html.Attributes exposing (..)
-import Gif
-
-
-
-main =
- App.program
- { init = init "funny cats" "funny dogs"
- , view = view
- , update = update
- , subscriptions = subscriptions
- }
-
-
-
--- MODEL
-
-
-type alias Model =
- { left : Gif.Model
- , right : Gif.Model
- }
-
-
-init : String -> String -> ( Model, Cmd Msg )
-init leftTopic rightTopic =
- let
- (left, leftFx) =
- Gif.init leftTopic
-
- (right, rightFx) =
- Gif.init rightTopic
- in
- ( Model left right
- , Cmd.batch
- [ Cmd.map Left leftFx
- , Cmd.map Right rightFx
- ]
- )
-
-
-
--- UPDATE
-
-
-type Msg
- = Left Gif.Msg
- | Right Gif.Msg
-
-
-update : Msg -> Model -> ( Model, Cmd Msg )
-update msg model =
- case msg of
- Left leftMsg ->
- let
- (left, leftCmds) =
- Gif.update leftMsg model.left
- in
- ( Model left model.right
- , Cmd.map Left leftCmds
- )
-
- Right rightMsg ->
- let
- (right, rightCmds) =
- Gif.update rightMsg model.right
- in
- ( Model model.left right
- , Cmd.map Right rightCmds
- )
-
-
-
--- VIEW
-
-
-view : Model -> Html Msg
-view model =
- div
- [ style [ ("display", "flex") ]
- ]
- [ App.map Left (Gif.view model.left)
- , App.map Right (Gif.view model.right)
- ]
-
-
-
--- SUBS
-
-
-subscriptions : Model -> Sub Msg
-subscriptions model =
- Sub.batch
- [ Sub.map Left (Gif.subscriptions model.left)
- , Sub.map Right (Gif.subscriptions model.right)
- ]
Oops, something went wrong.

1 comment on commit 82243d2

@nitingupta910

This comment has been minimized.

Show comment
Hide comment
@nitingupta910

nitingupta910 Sep 16, 2016

Would it be possible to bring back at least the IndexedCounter example? I think it's quite common to have a list of things (files under dir, out/in edges from/to nodes in graph etc.). I personally use this pattern everyday and find it quite useful.

nitingupta910 commented on 82243d2 Sep 16, 2016

Would it be possible to bring back at least the IndexedCounter example? I think it's quite common to have a list of things (files under dir, out/in edges from/to nodes in graph etc.). I personally use this pattern everyday and find it quite useful.

Please sign in to comment.