├── .gitignore ├── chapter-2 ├── 2.10-elm-install │ └── beginning-elm │ │ ├── elm.json │ │ ├── homepage.html │ │ ├── index.html │ │ └── src │ │ └── HomePage.elm └── 2.3-building-a-simple-web-page │ └── beginning-elm │ ├── elm.json │ ├── homepage.html │ ├── index.html │ └── src │ └── HomePage.elm ├── chapter-3 ├── 3.10-function │ └── beginning-elm │ │ ├── elm.json │ │ ├── homepage.html │ │ ├── index.html │ │ └── src │ │ ├── HomePage.elm │ │ └── Playground.elm ├── 3.11-let-expression │ └── beginning-elm │ │ ├── elm.json │ │ ├── homepage.html │ │ ├── index.html │ │ └── src │ │ ├── HomePage.elm │ │ └── Playground.elm ├── 3.12-case-expression │ └── beginning-elm │ │ ├── elm.json │ │ ├── homepage.html │ │ ├── index.html │ │ └── src │ │ ├── HomePage.elm │ │ └── Playground.elm ├── 3.14-string │ └── beginning-elm │ │ ├── elm.json │ │ ├── homepage.html │ │ ├── index.html │ │ └── src │ │ ├── HomePage.elm │ │ └── Playground.elm ├── 3.15-regular-expression │ └── beginning-elm │ │ ├── elm.json │ │ ├── homepage.html │ │ ├── index.html │ │ └── src │ │ ├── HomePage.elm │ │ └── Playground.elm ├── 3.16-list │ └── beginning-elm │ │ ├── elm.json │ │ ├── homepage.html │ │ ├── index.html │ │ └── src │ │ ├── HomePage.elm │ │ └── Playground.elm └── 3.18-tuple │ └── beginning-elm │ ├── elm.json │ ├── homepage.html │ ├── index.html │ └── src │ ├── HomePage.elm │ └── Playground.elm ├── chapter-4 ├── 4.2-immutability │ └── beginning-elm │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ └── src │ │ ├── HomePage.elm │ │ └── Playground.elm ├── 4.3-pure-functions │ └── beginning-elm │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ └── src │ │ ├── HomePage.elm │ │ └── Playground.elm ├── 4.4-solving-complex-problems │ └── beginning-elm │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ └── src │ │ ├── HomePage.elm │ │ ├── Playground.elm │ │ └── RippleCarryAdder.elm ├── 4.5-easy-to-test │ └── beginning-elm │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── src │ │ ├── HomePage.elm │ │ ├── Playground.elm │ │ └── RippleCarryAdder.elm │ │ └── tests │ │ ├── Example.elm │ │ └── RippleCarryAdderTests.elm ├── 4.6-type-system │ └── beginning-elm │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── src │ │ ├── HomePage.elm │ │ ├── Playground.elm │ │ └── RippleCarryAdder.elm │ │ └── tests │ │ ├── Example.elm │ │ └── RippleCarryAdderTests.elm ├── 4.7-easier-code-organization │ └── beginning-elm │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── src │ │ ├── HomePage.elm │ │ ├── MyList.elm │ │ ├── Playground.elm │ │ └── RippleCarryAdder.elm │ │ └── tests │ │ ├── Example.elm │ │ └── RippleCarryAdderTests.elm ├── 4.8-fuzz-testing │ └── beginning-elm │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── src │ │ ├── HomePage.elm │ │ ├── MyList.elm │ │ ├── Playground.elm │ │ └── RippleCarryAdder.elm │ │ └── tests │ │ ├── Example.elm │ │ ├── FuzzTests.elm │ │ └── RippleCarryAdderTests.elm └── 4.9-pattern-matching │ └── beginning-elm │ ├── elm.json │ ├── experiment.js │ ├── homepage.html │ ├── index.html │ ├── src │ ├── HomePage.elm │ ├── MyList.elm │ ├── Playground.elm │ └── RippleCarryAdder.elm │ └── tests │ ├── Example.elm │ ├── FuzzTests.elm │ └── RippleCarryAdderTests.elm ├── chapter-5 ├── 5.2-model-view-update-part-1 │ └── beginning-elm │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── src │ │ ├── Counter.elm │ │ ├── HomePage.elm │ │ ├── MyList.elm │ │ ├── Playground.elm │ │ └── RippleCarryAdder.elm │ │ └── tests │ │ ├── Example.elm │ │ ├── FuzzTests.elm │ │ └── RippleCarryAdderTests.elm ├── 5.3-virtual-dom │ └── beginning-elm │ │ ├── dom-performance-test.js │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── src │ │ ├── Counter.elm │ │ ├── HomePage.elm │ │ ├── MyList.elm │ │ ├── Playground.elm │ │ └── RippleCarryAdder.elm │ │ └── tests │ │ ├── Example.elm │ │ ├── FuzzTests.elm │ │ └── RippleCarryAdderTests.elm ├── 5.4-model-view-update-part-2 │ └── beginning-elm │ │ ├── dom-performance-test.js │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── signup-style.css │ │ ├── signup.html │ │ ├── signup.js │ │ ├── src │ │ ├── Counter.elm │ │ ├── HomePage.elm │ │ ├── MyList.elm │ │ ├── Playground.elm │ │ ├── RippleCarryAdder.elm │ │ └── Signup.elm │ │ └── tests │ │ ├── Example.elm │ │ ├── FuzzTests.elm │ │ └── RippleCarryAdderTests.elm └── 5.6-commands │ └── beginning-elm │ ├── dom-performance-test.js │ ├── elm.json │ ├── experiment.js │ ├── homepage.html │ ├── index.html │ ├── signup-style.css │ ├── signup.html │ ├── signup.js │ ├── src │ ├── Counter.elm │ ├── HomePage.elm │ ├── MyList.elm │ ├── Playground.elm │ ├── Profile.elm │ ├── RandomNumber.elm │ ├── RippleCarryAdder.elm │ └── Signup.elm │ └── tests │ ├── Example.elm │ ├── FuzzTests.elm │ └── RippleCarryAdderTests.elm ├── chapter-6 ├── 6.2-fetching-data-using-get │ └── beginning-elm │ │ ├── dom-performance-test.js │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── server │ │ └── old-school.txt │ │ ├── signup-style.css │ │ ├── signup.html │ │ ├── signup.js │ │ ├── src │ │ ├── Counter.elm │ │ ├── HomePage.elm │ │ ├── HttpExamples.elm │ │ ├── MyList.elm │ │ ├── Playground.elm │ │ ├── Profile.elm │ │ ├── RandomNumber.elm │ │ ├── RippleCarryAdder.elm │ │ └── Signup.elm │ │ └── tests │ │ ├── Example.elm │ │ ├── FuzzTests.elm │ │ └── RippleCarryAdderTests.elm ├── 6.3-decoding-json-part-1 │ └── beginning-elm │ │ ├── dom-performance-test.js │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── server │ │ ├── db.json │ │ ├── old-school.json │ │ └── old-school.txt │ │ ├── signup-style.css │ │ ├── signup.html │ │ ├── signup.js │ │ ├── src │ │ ├── Counter.elm │ │ ├── HomePage.elm │ │ ├── HttpExamples.elm │ │ ├── MyList.elm │ │ ├── Playground.elm │ │ ├── Profile.elm │ │ ├── RandomNumber.elm │ │ ├── RippleCarryAdder.elm │ │ └── Signup.elm │ │ └── tests │ │ ├── Example.elm │ │ ├── FuzzTests.elm │ │ └── RippleCarryAdderTests.elm ├── 6.4-decoding-json-part-2 │ └── beginning-elm │ │ ├── dom-performance-test.js │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── server │ │ ├── db.json │ │ ├── old-school.json │ │ └── old-school.txt │ │ ├── signup-style.css │ │ ├── signup.html │ │ ├── signup.js │ │ ├── src │ │ ├── Counter.elm │ │ ├── DecodingJson.elm │ │ ├── HomePage.elm │ │ ├── HttpExamples.elm │ │ ├── MyList.elm │ │ ├── Playground.elm │ │ ├── Profile.elm │ │ ├── RandomNumber.elm │ │ ├── RippleCarryAdder.elm │ │ └── Signup.elm │ │ └── tests │ │ ├── Example.elm │ │ ├── FuzzTests.elm │ │ └── RippleCarryAdderTests.elm ├── 6.5-remote-data │ └── beginning-elm │ │ ├── dom-performance-test.js │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── server │ │ ├── db.json │ │ ├── old-school.json │ │ └── old-school.txt │ │ ├── signup-style.css │ │ ├── signup.html │ │ ├── signup.js │ │ ├── src │ │ ├── Counter.elm │ │ ├── DecodingJson.elm │ │ ├── HomePage.elm │ │ ├── HttpExamples.elm │ │ ├── MyList.elm │ │ ├── Playground.elm │ │ ├── Profile.elm │ │ ├── RandomNumber.elm │ │ ├── RippleCarryAdder.elm │ │ └── Signup.elm │ │ └── tests │ │ ├── Example.elm │ │ ├── FuzzTests.elm │ │ └── RippleCarryAdderTests.elm └── 6.6-retrieving-data-on-initialization │ └── beginning-elm │ ├── dom-performance-test.js │ ├── elm.json │ ├── experiment.js │ ├── homepage.html │ ├── index.html │ ├── server │ ├── db.json │ ├── old-school.json │ └── old-school.txt │ ├── signup-style.css │ ├── signup.html │ ├── signup.js │ ├── src │ ├── Counter.elm │ ├── DecodingJson.elm │ ├── HomePage.elm │ ├── HttpExamples.elm │ ├── MyList.elm │ ├── Playground.elm │ ├── Profile.elm │ ├── RandomNumber.elm │ ├── RippleCarryAdder.elm │ └── Signup.elm │ └── tests │ ├── Example.elm │ ├── FuzzTests.elm │ └── RippleCarryAdderTests.elm ├── chapter-7 ├── 7.4-creating-post-module │ └── beginning-elm │ │ ├── dom-performance-test.js │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── post-app │ │ └── Post.elm │ │ ├── server │ │ ├── db.json │ │ ├── old-school.json │ │ └── old-school.txt │ │ ├── signup-style.css │ │ ├── signup.html │ │ ├── signup.js │ │ ├── src │ │ ├── Counter.elm │ │ ├── DecodingJson.elm │ │ ├── HomePage.elm │ │ ├── HttpExamples.elm │ │ ├── MyList.elm │ │ ├── Playground.elm │ │ ├── Profile.elm │ │ ├── RandomNumber.elm │ │ ├── RippleCarryAdder.elm │ │ └── Signup.elm │ │ └── tests │ │ ├── Example.elm │ │ ├── FuzzTests.elm │ │ └── RippleCarryAdderTests.elm ├── 7.5-creating-list-posts-page │ └── beginning-elm │ │ ├── dom-performance-test.js │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── post-app │ │ ├── Main.elm │ │ ├── Page │ │ │ └── ListPosts.elm │ │ └── Post.elm │ │ ├── server │ │ ├── db.json │ │ ├── old-school.json │ │ └── old-school.txt │ │ ├── signup-style.css │ │ ├── signup.html │ │ ├── signup.js │ │ ├── src │ │ ├── Counter.elm │ │ ├── DecodingJson.elm │ │ ├── HomePage.elm │ │ ├── HttpExamples.elm │ │ ├── MyList.elm │ │ ├── Playground.elm │ │ ├── Profile.elm │ │ ├── RandomNumber.elm │ │ ├── RippleCarryAdder.elm │ │ └── Signup.elm │ │ └── tests │ │ ├── Example.elm │ │ ├── FuzzTests.elm │ │ └── RippleCarryAdderTests.elm ├── 7.6-navigating-to-list-posts-page │ └── beginning-elm │ │ ├── dom-performance-test.js │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── post-app │ │ ├── Main.elm │ │ ├── Page │ │ │ └── ListPosts.elm │ │ ├── Post.elm │ │ └── Route.elm │ │ ├── server │ │ ├── db.json │ │ ├── old-school.json │ │ └── old-school.txt │ │ ├── signup-style.css │ │ ├── signup.html │ │ ├── signup.js │ │ ├── src │ │ ├── Counter.elm │ │ ├── DecodingJson.elm │ │ ├── HomePage.elm │ │ ├── HttpExamples.elm │ │ ├── MyList.elm │ │ ├── Playground.elm │ │ ├── Profile.elm │ │ ├── RandomNumber.elm │ │ ├── RippleCarryAdder.elm │ │ └── Signup.elm │ │ └── tests │ │ ├── Example.elm │ │ ├── FuzzTests.elm │ │ └── RippleCarryAdderTests.elm ├── 7.7-editing-a-post │ └── beginning-elm │ │ ├── dom-performance-test.js │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── post-app │ │ ├── Error.elm │ │ ├── Main.elm │ │ ├── Page │ │ │ ├── EditPost.elm │ │ │ └── ListPosts.elm │ │ ├── Post.elm │ │ └── Route.elm │ │ ├── server │ │ ├── db.json │ │ ├── old-school.json │ │ └── old-school.txt │ │ ├── signup-style.css │ │ ├── signup.html │ │ ├── signup.js │ │ ├── src │ │ ├── Counter.elm │ │ ├── DecodingJson.elm │ │ ├── HomePage.elm │ │ ├── HttpExamples.elm │ │ ├── MyList.elm │ │ ├── Playground.elm │ │ ├── Profile.elm │ │ ├── RandomNumber.elm │ │ ├── RippleCarryAdder.elm │ │ └── Signup.elm │ │ └── tests │ │ ├── Example.elm │ │ ├── FuzzTests.elm │ │ └── RippleCarryAdderTests.elm ├── 7.8-deleting-a-post │ └── beginning-elm │ │ ├── dom-performance-test.js │ │ ├── elm.json │ │ ├── experiment.js │ │ ├── homepage.html │ │ ├── index.html │ │ ├── post-app │ │ ├── Error.elm │ │ ├── Main.elm │ │ ├── Page │ │ │ ├── EditPost.elm │ │ │ └── ListPosts.elm │ │ ├── Post.elm │ │ └── Route.elm │ │ ├── server │ │ ├── db.json │ │ ├── old-school.json │ │ └── old-school.txt │ │ ├── signup-style.css │ │ ├── signup.html │ │ ├── signup.js │ │ ├── src │ │ ├── Counter.elm │ │ ├── DecodingJson.elm │ │ ├── HomePage.elm │ │ ├── HttpExamples.elm │ │ ├── MyList.elm │ │ ├── Playground.elm │ │ ├── Profile.elm │ │ ├── RandomNumber.elm │ │ ├── RippleCarryAdder.elm │ │ └── Signup.elm │ │ └── tests │ │ ├── Example.elm │ │ ├── FuzzTests.elm │ │ └── RippleCarryAdderTests.elm └── 7.9-creating-a-new-post │ └── beginning-elm │ ├── dom-performance-test.js │ ├── elm.json │ ├── experiment.js │ ├── homepage.html │ ├── index.html │ ├── post-app │ ├── Error.elm │ ├── Main.elm │ ├── Page │ │ ├── EditPost.elm │ │ ├── ListPosts.elm │ │ └── NewPost.elm │ ├── Post.elm │ └── Route.elm │ ├── server │ ├── db.json │ ├── old-school.json │ └── old-school.txt │ ├── signup-style.css │ ├── signup.html │ ├── signup.js │ ├── src │ ├── Counter.elm │ ├── DecodingJson.elm │ ├── HomePage.elm │ ├── HttpExamples.elm │ ├── MyList.elm │ ├── Playground.elm │ ├── Profile.elm │ ├── RandomNumber.elm │ ├── RippleCarryAdder.elm │ └── Signup.elm │ └── tests │ ├── Example.elm │ ├── FuzzTests.elm │ └── RippleCarryAdderTests.elm └── chapter-8 ├── 8.2-sending-data-to-javascript └── beginning-elm │ ├── dom-performance-test.js │ ├── elm.json │ ├── experiment.js │ ├── homepage.html │ ├── index.html │ ├── post-app │ ├── Error.elm │ ├── Main.elm │ ├── Page │ │ ├── EditPost.elm │ │ ├── ListPosts.elm │ │ └── NewPost.elm │ ├── Post.elm │ └── Route.elm │ ├── server │ ├── db.json │ ├── old-school.json │ └── old-school.txt │ ├── signup-style.css │ ├── signup.html │ ├── signup.js │ ├── src │ ├── Counter.elm │ ├── DecodingJson.elm │ ├── HomePage.elm │ ├── HttpExamples.elm │ ├── MyList.elm │ ├── Playground.elm │ ├── PortExamples.elm │ ├── Profile.elm │ ├── RandomNumber.elm │ ├── RippleCarryAdder.elm │ └── Signup.elm │ └── tests │ ├── Example.elm │ ├── FuzzTests.elm │ └── RippleCarryAdderTests.elm ├── 8.3-subscriptions └── beginning-elm │ ├── dom-performance-test.js │ ├── elm.json │ ├── experiment.js │ ├── homepage.html │ ├── index.html │ ├── post-app │ ├── Error.elm │ ├── Main.elm │ ├── Page │ │ ├── EditPost.elm │ │ ├── ListPosts.elm │ │ └── NewPost.elm │ ├── Post.elm │ └── Route.elm │ ├── server │ ├── db.json │ ├── old-school.json │ └── old-school.txt │ ├── signup-style.css │ ├── signup.html │ ├── signup.js │ ├── src │ ├── Counter.elm │ ├── DecodingJson.elm │ ├── EventListener.elm │ ├── HomePage.elm │ ├── HttpExamples.elm │ ├── MyList.elm │ ├── Playground.elm │ ├── PortExamples.elm │ ├── Profile.elm │ ├── RandomNumber.elm │ ├── RippleCarryAdder.elm │ └── Signup.elm │ └── tests │ ├── Example.elm │ ├── FuzzTests.elm │ └── RippleCarryAdderTests.elm ├── 8.4-receiving-data-from-javascript └── beginning-elm │ ├── dom-performance-test.js │ ├── elm.json │ ├── experiment.js │ ├── homepage.html │ ├── index.html │ ├── post-app │ ├── Error.elm │ ├── Main.elm │ ├── Page │ │ ├── EditPost.elm │ │ ├── ListPosts.elm │ │ └── NewPost.elm │ ├── Post.elm │ └── Route.elm │ ├── server │ ├── db.json │ ├── old-school.json │ └── old-school.txt │ ├── signup-style.css │ ├── signup.html │ ├── signup.js │ ├── src │ ├── Counter.elm │ ├── DecodingJson.elm │ ├── EventListener.elm │ ├── HomePage.elm │ ├── HttpExamples.elm │ ├── MyList.elm │ ├── Playground.elm │ ├── PortExamples.elm │ ├── Profile.elm │ ├── RandomNumber.elm │ ├── RippleCarryAdder.elm │ └── Signup.elm │ └── tests │ ├── Example.elm │ ├── FuzzTests.elm │ └── RippleCarryAdderTests.elm ├── 8.5-protecting-boundaries └── beginning-elm │ ├── dom-performance-test.js │ ├── elm.json │ ├── experiment.js │ ├── homepage.html │ ├── index.html │ ├── post-app │ ├── Error.elm │ ├── Main.elm │ ├── Page │ │ ├── EditPost.elm │ │ ├── ListPosts.elm │ │ └── NewPost.elm │ ├── Post.elm │ └── Route.elm │ ├── server │ ├── db.json │ ├── old-school.json │ └── old-school.txt │ ├── signup-style.css │ ├── signup.html │ ├── signup.js │ ├── src │ ├── Counter.elm │ ├── DecodingJson.elm │ ├── EventListener.elm │ ├── HomePage.elm │ ├── HttpExamples.elm │ ├── MyList.elm │ ├── Playground.elm │ ├── PortExamples.elm │ ├── Profile.elm │ ├── RandomNumber.elm │ ├── RippleCarryAdder.elm │ └── Signup.elm │ └── tests │ ├── Example.elm │ ├── FuzzTests.elm │ └── RippleCarryAdderTests.elm ├── 8.6-saving-app-state └── beginning-elm │ ├── dom-performance-test.js │ ├── elm.json │ ├── experiment.js │ ├── homepage.html │ ├── index.html │ ├── post-app │ ├── Error.elm │ ├── Main.elm │ ├── Page │ │ ├── EditPost.elm │ │ ├── ListPosts.elm │ │ └── NewPost.elm │ ├── Ports.elm │ ├── Post.elm │ └── Route.elm │ ├── server │ ├── db.json │ ├── old-school.json │ └── old-school.txt │ ├── signup-style.css │ ├── signup.html │ ├── signup.js │ ├── src │ ├── Counter.elm │ ├── DecodingJson.elm │ ├── EventListener.elm │ ├── HomePage.elm │ ├── HttpExamples.elm │ ├── MyList.elm │ ├── Playground.elm │ ├── PortExamples.elm │ ├── Profile.elm │ ├── RandomNumber.elm │ ├── RippleCarryAdder.elm │ └── Signup.elm │ └── tests │ ├── Example.elm │ ├── FuzzTests.elm │ └── RippleCarryAdderTests.elm ├── 8.7-retrieving-app-state └── beginning-elm │ ├── dom-performance-test.js │ ├── elm.json │ ├── experiment.js │ ├── homepage.html │ ├── index.html │ ├── post-app │ ├── Error.elm │ ├── Main.elm │ ├── Page │ │ ├── EditPost.elm │ │ ├── ListPosts.elm │ │ └── NewPost.elm │ ├── Ports.elm │ ├── Post.elm │ └── Route.elm │ ├── server │ ├── db.json │ ├── old-school.json │ └── old-school.txt │ ├── signup-style.css │ ├── signup.html │ ├── signup.js │ ├── src │ ├── Counter.elm │ ├── DecodingJson.elm │ ├── EventListener.elm │ ├── HomePage.elm │ ├── HttpExamples.elm │ ├── MyList.elm │ ├── Playground.elm │ ├── PortExamples.elm │ ├── Profile.elm │ ├── RandomNumber.elm │ ├── RippleCarryAdder.elm │ └── Signup.elm │ └── tests │ ├── Example.elm │ ├── FuzzTests.elm │ └── RippleCarryAdderTests.elm └── 8.8-interacting-with-web-components └── beginning-elm ├── assets └── images │ └── waterfall.jpg ├── dom-performance-test.js ├── elm.json ├── experiment.js ├── homepage.html ├── index.html ├── node_modules └── @github │ └── image-crop-element │ ├── LICENSE │ ├── dist │ ├── index.esm.js │ ├── index.esm.js.flow │ ├── index.umd.js │ └── index.umd.js.flow │ ├── index.css │ ├── index.d.ts │ ├── package.json │ └── readme.md ├── package-lock.json ├── package.json ├── post-app ├── Error.elm ├── Main.elm ├── Page │ ├── EditPost.elm │ ├── ListPosts.elm │ └── NewPost.elm ├── Ports.elm ├── Post.elm └── Route.elm ├── server ├── db.json ├── old-school.json └── old-school.txt ├── signup-style.css ├── signup.html ├── signup.js ├── src ├── Asset.elm ├── Counter.elm ├── CustomElements.elm ├── DecodingJson.elm ├── EventListener.elm ├── HomePage.elm ├── HttpExamples.elm ├── MyList.elm ├── Playground.elm ├── PortExamples.elm ├── Profile.elm ├── RandomNumber.elm ├── RippleCarryAdder.elm └── Signup.elm └── tests ├── Example.elm ├── FuzzTests.elm └── RippleCarryAdderTests.elm /.gitignore: -------------------------------------------------------------------------------- 1 | # elm-package generated files 2 | elm-stuff/ 3 | # elm-repl generated files 4 | repl-temp-* 5 | 6 | elm.js 7 | -------------------------------------------------------------------------------- /chapter-2/2.10-elm-install/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0" 13 | }, 14 | "indirect": { 15 | "elm/bytes": "1.0.8", 16 | "elm/file": "1.0.5", 17 | "elm/json": "1.1.3", 18 | "elm/time": "1.0.0", 19 | "elm/url": "1.0.0", 20 | "elm/virtual-dom": "1.0.2" 21 | } 22 | }, 23 | "test-dependencies": { 24 | "direct": {}, 25 | "indirect": {} 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /chapter-2/2.10-elm-install/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-2/2.10-elm-install/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-2/2.10-elm-install/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view model = 8 | div [ class "jumbotron" ] 9 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 10 | , p [] 11 | [ text "Dunder Mifflin Inc. (stock symbol " 12 | , strong [] [ text "DMI" ] 13 | , text <| 14 | """ 15 | ) is a micro-cap regional paper and office 16 | supply distributor with an emphasis on servicing 17 | small-business clients. 18 | """ 19 | ] 20 | ] 21 | 22 | 23 | main = 24 | view "dummy model" 25 | -------------------------------------------------------------------------------- /chapter-2/2.3-building-a-simple-web-page/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0" 12 | }, 13 | "indirect": { 14 | "elm/json": "1.1.3", 15 | "elm/time": "1.0.0", 16 | "elm/url": "1.0.0", 17 | "elm/virtual-dom": "1.0.2" 18 | } 19 | }, 20 | "test-dependencies": { 21 | "direct": {}, 22 | "indirect": {} 23 | } 24 | } -------------------------------------------------------------------------------- /chapter-2/2.3-building-a-simple-web-page/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-2/2.3-building-a-simple-web-page/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-2/2.3-building-a-simple-web-page/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view model = 8 | div [ class "jumbotron" ] 9 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 10 | , p [] 11 | [ text "Dunder Mifflin Inc. (stock symbol " 12 | , strong [] [ text "DMI" ] 13 | , text <| 14 | """ 15 | ) is a micro-cap regional paper and office 16 | supply distributor with an emphasis on servicing 17 | small-business clients. 18 | """ 19 | ] 20 | ] 21 | 22 | 23 | main = 24 | view "dummy model" 25 | -------------------------------------------------------------------------------- /chapter-3/3.10-function/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0" 13 | }, 14 | "indirect": { 15 | "elm/bytes": "1.0.8", 16 | "elm/file": "1.0.5", 17 | "elm/json": "1.1.3", 18 | "elm/time": "1.0.0", 19 | "elm/url": "1.0.0", 20 | "elm/virtual-dom": "1.0.2" 21 | } 22 | }, 23 | "test-dependencies": { 24 | "direct": {}, 25 | "indirect": {} 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /chapter-3/3.10-function/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-3/3.10-function/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-3/3.10-function/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view model = 8 | div [ class "jumbotron" ] 9 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 10 | , p [] 11 | [ text "Dunder Mifflin Inc. (stock symbol " 12 | , strong [] [ text "DMI" ] 13 | , text <| 14 | """ 15 | ) is a micro-cap regional paper and office 16 | supply distributor with an emphasis on servicing 17 | small-business clients. 18 | """ 19 | ] 20 | ] 21 | 22 | 23 | main = 24 | view "dummy model" 25 | -------------------------------------------------------------------------------- /chapter-3/3.10-function/beginning-elm/src/Playground.elm: -------------------------------------------------------------------------------- 1 | module Playground exposing (main) 2 | 3 | import Html 4 | 5 | 6 | escapeEarth myVelocity mySpeed = 7 | if myVelocity > 11.186 then 8 | "Godspeed" 9 | 10 | else if mySpeed == 7.67 then 11 | "Stay in orbit" 12 | 13 | else 14 | "Come back" 15 | 16 | 17 | computeSpeed distance time = 18 | distance / time 19 | 20 | 21 | computeTime startTime endTime = 22 | endTime - startTime 23 | 24 | 25 | add a b = 26 | a + b 27 | 28 | 29 | multiply c d = 30 | c * d 31 | 32 | 33 | divide e f = 34 | e / f 35 | 36 | 37 | main = 38 | Html.text <| String.fromFloat <| add 5 <| multiply 10 <| divide 30 10 39 | -------------------------------------------------------------------------------- /chapter-3/3.11-let-expression/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0" 13 | }, 14 | "indirect": { 15 | "elm/bytes": "1.0.8", 16 | "elm/file": "1.0.5", 17 | "elm/json": "1.1.3", 18 | "elm/time": "1.0.0", 19 | "elm/url": "1.0.0", 20 | "elm/virtual-dom": "1.0.2" 21 | } 22 | }, 23 | "test-dependencies": { 24 | "direct": {}, 25 | "indirect": {} 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /chapter-3/3.11-let-expression/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-3/3.11-let-expression/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-3/3.11-let-expression/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view model = 8 | div [ class "jumbotron" ] 9 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 10 | , p [] 11 | [ text "Dunder Mifflin Inc. (stock symbol " 12 | , strong [] [ text "DMI" ] 13 | , text <| 14 | """ 15 | ) is a micro-cap regional paper and office 16 | supply distributor with an emphasis on servicing 17 | small-business clients. 18 | """ 19 | ] 20 | ] 21 | 22 | 23 | main = 24 | view "dummy model" 25 | -------------------------------------------------------------------------------- /chapter-3/3.12-case-expression/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0" 13 | }, 14 | "indirect": { 15 | "elm/bytes": "1.0.8", 16 | "elm/file": "1.0.5", 17 | "elm/json": "1.1.3", 18 | "elm/time": "1.0.0", 19 | "elm/url": "1.0.0", 20 | "elm/virtual-dom": "1.0.2" 21 | } 22 | }, 23 | "test-dependencies": { 24 | "direct": {}, 25 | "indirect": {} 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /chapter-3/3.12-case-expression/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-3/3.12-case-expression/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-3/3.12-case-expression/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view model = 8 | div [ class "jumbotron" ] 9 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 10 | , p [] 11 | [ text "Dunder Mifflin Inc. (stock symbol " 12 | , strong [] [ text "DMI" ] 13 | , text <| 14 | """ 15 | ) is a micro-cap regional paper and office 16 | supply distributor with an emphasis on servicing 17 | small-business clients. 18 | """ 19 | ] 20 | ] 21 | 22 | 23 | main = 24 | view "dummy model" 25 | -------------------------------------------------------------------------------- /chapter-3/3.14-string/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0" 13 | }, 14 | "indirect": { 15 | "elm/bytes": "1.0.8", 16 | "elm/file": "1.0.5", 17 | "elm/json": "1.1.3", 18 | "elm/time": "1.0.0", 19 | "elm/url": "1.0.0", 20 | "elm/virtual-dom": "1.0.2" 21 | } 22 | }, 23 | "test-dependencies": { 24 | "direct": {}, 25 | "indirect": {} 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /chapter-3/3.14-string/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-3/3.14-string/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-3/3.14-string/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view model = 8 | div [ class "jumbotron" ] 9 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 10 | , p [] 11 | [ text "Dunder Mifflin Inc. (stock symbol " 12 | , strong [] [ text "DMI" ] 13 | , text <| 14 | """ 15 | ) is a micro-cap regional paper and office 16 | supply distributor with an emphasis on servicing 17 | small-business clients. 18 | """ 19 | ] 20 | ] 21 | 22 | 23 | main = 24 | view "dummy model" 25 | -------------------------------------------------------------------------------- /chapter-3/3.15-regular-expression/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0", 13 | "elm/regex": "1.0.0" 14 | }, 15 | "indirect": { 16 | "elm/bytes": "1.0.8", 17 | "elm/file": "1.0.5", 18 | "elm/json": "1.1.3", 19 | "elm/time": "1.0.0", 20 | "elm/url": "1.0.0", 21 | "elm/virtual-dom": "1.0.2" 22 | } 23 | }, 24 | "test-dependencies": { 25 | "direct": {}, 26 | "indirect": {} 27 | } 28 | } -------------------------------------------------------------------------------- /chapter-3/3.15-regular-expression/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-3/3.15-regular-expression/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-3/3.15-regular-expression/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view model = 8 | div [ class "jumbotron" ] 9 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 10 | , p [] 11 | [ text "Dunder Mifflin Inc. (stock symbol " 12 | , strong [] [ text "DMI" ] 13 | , text <| 14 | """ 15 | ) is a micro-cap regional paper and office 16 | supply distributor with an emphasis on servicing 17 | small-business clients. 18 | """ 19 | ] 20 | ] 21 | 22 | 23 | main = 24 | view "dummy model" 25 | -------------------------------------------------------------------------------- /chapter-3/3.16-list/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0", 13 | "elm/regex": "1.0.0" 14 | }, 15 | "indirect": { 16 | "elm/bytes": "1.0.8", 17 | "elm/file": "1.0.5", 18 | "elm/json": "1.1.3", 19 | "elm/time": "1.0.0", 20 | "elm/url": "1.0.0", 21 | "elm/virtual-dom": "1.0.2" 22 | } 23 | }, 24 | "test-dependencies": { 25 | "direct": {}, 26 | "indirect": {} 27 | } 28 | } -------------------------------------------------------------------------------- /chapter-3/3.16-list/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-3/3.16-list/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-3/3.16-list/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view model = 8 | div [ class "jumbotron" ] 9 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 10 | , p [] 11 | [ text "Dunder Mifflin Inc. (stock symbol " 12 | , strong [] [ text "DMI" ] 13 | , text <| 14 | """ 15 | ) is a micro-cap regional paper and office 16 | supply distributor with an emphasis on servicing 17 | small-business clients. 18 | """ 19 | ] 20 | ] 21 | 22 | 23 | main = 24 | view "dummy model" 25 | -------------------------------------------------------------------------------- /chapter-3/3.18-tuple/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0", 13 | "elm/regex": "1.0.0" 14 | }, 15 | "indirect": { 16 | "elm/bytes": "1.0.8", 17 | "elm/file": "1.0.5", 18 | "elm/json": "1.1.3", 19 | "elm/time": "1.0.0", 20 | "elm/url": "1.0.0", 21 | "elm/virtual-dom": "1.0.2" 22 | } 23 | }, 24 | "test-dependencies": { 25 | "direct": {}, 26 | "indirect": {} 27 | } 28 | } -------------------------------------------------------------------------------- /chapter-3/3.18-tuple/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-3/3.18-tuple/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-3/3.18-tuple/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view model = 8 | div [ class "jumbotron" ] 9 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 10 | , p [] 11 | [ text "Dunder Mifflin Inc. (stock symbol " 12 | , strong [] [ text "DMI" ] 13 | , text <| 14 | """ 15 | ) is a micro-cap regional paper and office 16 | supply distributor with an emphasis on servicing 17 | small-business clients. 18 | """ 19 | ] 20 | ] 21 | 22 | 23 | main = 24 | view "dummy model" 25 | -------------------------------------------------------------------------------- /chapter-4/4.2-immutability/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0", 13 | "elm/regex": "1.0.0" 14 | }, 15 | "indirect": { 16 | "elm/bytes": "1.0.8", 17 | "elm/file": "1.0.5", 18 | "elm/json": "1.1.3", 19 | "elm/time": "1.0.0", 20 | "elm/url": "1.0.0", 21 | "elm/virtual-dom": "1.0.2" 22 | } 23 | }, 24 | "test-dependencies": { 25 | "direct": {}, 26 | "indirect": {} 27 | } 28 | } -------------------------------------------------------------------------------- /chapter-4/4.2-immutability/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | var newScores = []; 6 | 7 | for (var i = 0; i < scores.length; i++) { 8 | newScores[i] = scores[i] * scoreMultiplier; 9 | } 10 | 11 | return newScores; 12 | } 13 | 14 | 15 | function scoresLessThan320(scores) { 16 | return scores.filter(isLessThan320); 17 | } 18 | 19 | function isLessThan320(score) { 20 | return score < 320; 21 | } 22 | -------------------------------------------------------------------------------- /chapter-4/4.2-immutability/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-4/4.2-immutability/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /chapter-4/4.2-immutability/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view model = 8 | div [ class "jumbotron" ] 9 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 10 | , p [] 11 | [ text "Dunder Mifflin Inc. (stock symbol " 12 | , strong [] [ text "DMI" ] 13 | , text <| 14 | """ 15 | ) is a micro-cap regional paper and office 16 | supply distributor with an emphasis on servicing 17 | small-business clients. 18 | """ 19 | ] 20 | ] 21 | 22 | 23 | main = 24 | view "dummy model" 25 | -------------------------------------------------------------------------------- /chapter-4/4.3-pure-functions/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0", 13 | "elm/regex": "1.0.0" 14 | }, 15 | "indirect": { 16 | "elm/bytes": "1.0.8", 17 | "elm/file": "1.0.5", 18 | "elm/json": "1.1.3", 19 | "elm/time": "1.0.0", 20 | "elm/url": "1.0.0", 21 | "elm/virtual-dom": "1.0.2" 22 | } 23 | }, 24 | "test-dependencies": { 25 | "direct": {}, 26 | "indirect": {} 27 | } 28 | } -------------------------------------------------------------------------------- /chapter-4/4.3-pure-functions/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | var newScores = []; 6 | 7 | for (var i = 0; i < scores.length; i++) { 8 | newScores[i] = scores[i] * scoreMultiplier; 9 | } 10 | 11 | scoreMultiplier = 3; 12 | 13 | return newScores; 14 | } 15 | 16 | 17 | function scoresLessThan320(scores) { 18 | return scores.filter(isLessThan320); 19 | } 20 | 21 | function isLessThan320(score) { 22 | return score < 320; 23 | } 24 | -------------------------------------------------------------------------------- /chapter-4/4.3-pure-functions/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-4/4.3-pure-functions/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /chapter-4/4.3-pure-functions/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view model = 8 | div [ class "jumbotron" ] 9 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 10 | , p [] 11 | [ text "Dunder Mifflin Inc. (stock symbol " 12 | , strong [] [ text "DMI" ] 13 | , text <| 14 | """ 15 | ) is a micro-cap regional paper and office 16 | supply distributor with an emphasis on servicing 17 | small-business clients. 18 | """ 19 | ] 20 | ] 21 | 22 | 23 | main = 24 | view "dummy model" 25 | -------------------------------------------------------------------------------- /chapter-4/4.4-solving-complex-problems/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0", 13 | "elm/regex": "1.0.0" 14 | }, 15 | "indirect": { 16 | "elm/bytes": "1.0.8", 17 | "elm/file": "1.0.5", 18 | "elm/json": "1.1.3", 19 | "elm/time": "1.0.0", 20 | "elm/url": "1.0.0", 21 | "elm/virtual-dom": "1.0.2" 22 | } 23 | }, 24 | "test-dependencies": { 25 | "direct": {}, 26 | "indirect": {} 27 | } 28 | } -------------------------------------------------------------------------------- /chapter-4/4.4-solving-complex-problems/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | var newScores = []; 6 | 7 | for (var i = 0; i < scores.length; i++) { 8 | newScores[i] = scores[i] * scoreMultiplier; 9 | } 10 | 11 | scoreMultiplier = 3; 12 | 13 | return newScores; 14 | } 15 | 16 | 17 | function scoresLessThan320(scores) { 18 | return scores.filter(isLessThan320); 19 | } 20 | 21 | function isLessThan320(score) { 22 | return score < 320; 23 | } 24 | -------------------------------------------------------------------------------- /chapter-4/4.4-solving-complex-problems/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-4/4.4-solving-complex-problems/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /chapter-4/4.4-solving-complex-problems/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view model = 8 | div [ class "jumbotron" ] 9 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 10 | , p [] 11 | [ text "Dunder Mifflin Inc. (stock symbol " 12 | , strong [] [ text "DMI" ] 13 | , text <| 14 | """ 15 | ) is a micro-cap regional paper and office 16 | supply distributor with an emphasis on servicing 17 | small-business clients. 18 | """ 19 | ] 20 | ] 21 | 22 | 23 | main = 24 | view "dummy model" 25 | -------------------------------------------------------------------------------- /chapter-4/4.5-easy-to-test/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0", 13 | "elm/json": "1.1.3", 14 | "elm/regex": "1.0.0" 15 | }, 16 | "indirect": { 17 | "elm/bytes": "1.0.8", 18 | "elm/file": "1.0.5", 19 | "elm/time": "1.0.0", 20 | "elm/url": "1.0.0", 21 | "elm/virtual-dom": "1.0.2" 22 | } 23 | }, 24 | "test-dependencies": { 25 | "direct": { 26 | "elm-explorations/test": "1.2.2" 27 | }, 28 | "indirect": { 29 | "elm/random": "1.0.0" 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /chapter-4/4.5-easy-to-test/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | var newScores = []; 6 | 7 | for (var i = 0; i < scores.length; i++) { 8 | newScores[i] = scores[i] * scoreMultiplier; 9 | } 10 | 11 | scoreMultiplier = 3; 12 | 13 | return newScores; 14 | } 15 | 16 | 17 | function scoresLessThan320(scores) { 18 | return scores.filter(isLessThan320); 19 | } 20 | 21 | function isLessThan320(score) { 22 | return score < 320; 23 | } 24 | -------------------------------------------------------------------------------- /chapter-4/4.5-easy-to-test/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-4/4.5-easy-to-test/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /chapter-4/4.5-easy-to-test/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view model = 8 | div [ class "jumbotron" ] 9 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 10 | , p [] 11 | [ text "Dunder Mifflin Inc. (stock symbol " 12 | , strong [] [ text "DMI" ] 13 | , text <| 14 | """ 15 | ) is a micro-cap regional paper and office 16 | supply distributor with an emphasis on servicing 17 | small-business clients. 18 | """ 19 | ] 20 | ] 21 | 22 | 23 | main = 24 | view "dummy model" 25 | -------------------------------------------------------------------------------- /chapter-4/4.6-type-system/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0", 13 | "elm/json": "1.1.3", 14 | "elm/regex": "1.0.0" 15 | }, 16 | "indirect": { 17 | "elm/bytes": "1.0.8", 18 | "elm/file": "1.0.5", 19 | "elm/time": "1.0.0", 20 | "elm/url": "1.0.0", 21 | "elm/virtual-dom": "1.0.2" 22 | } 23 | }, 24 | "test-dependencies": { 25 | "direct": { 26 | "elm-explorations/test": "1.2.2" 27 | }, 28 | "indirect": { 29 | "elm/random": "1.0.0" 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /chapter-4/4.6-type-system/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | 6 | // Reject non-list type inputs 7 | if (Array.isArray(scores) === false) { 8 | throw new Error("Input must be of type array"); 9 | } 10 | 11 | var newScores = []; 12 | 13 | for (var i = 0; i < scores.length; i++) { 14 | 15 | // Reject arrays that contain values that are not numbers 16 | if (typeof scores[i] !== "number") { 17 | throw new Error("Input array must contain numbers only"); 18 | } 19 | else { 20 | newScores[i] = scores[i] * scoreMultiplier; 21 | } 22 | } 23 | 24 | return newScores; 25 | } 26 | 27 | 28 | function scoresLessThan320(scores) { 29 | return scores.filter(isLessThan320); 30 | } 31 | 32 | function isLessThan320(score) { 33 | return score < 320; 34 | } 35 | -------------------------------------------------------------------------------- /chapter-4/4.6-type-system/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-4/4.6-type-system/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /chapter-4/4.6-type-system/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view model = 8 | div [ class "jumbotron" ] 9 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 10 | , p [] 11 | [ text "Dunder Mifflin Inc. (stock symbol " 12 | , strong [] [ text "DMI" ] 13 | , text <| 14 | """ 15 | ) is a micro-cap regional paper and office 16 | supply distributor with an emphasis on servicing 17 | small-business clients. 18 | """ 19 | ] 20 | ] 21 | 22 | 23 | main = 24 | view "dummy model" 25 | -------------------------------------------------------------------------------- /chapter-4/4.7-easier-code-organization/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0", 13 | "elm/json": "1.1.3", 14 | "elm/regex": "1.0.0" 15 | }, 16 | "indirect": { 17 | "elm/bytes": "1.0.8", 18 | "elm/file": "1.0.5", 19 | "elm/time": "1.0.0", 20 | "elm/url": "1.0.0", 21 | "elm/virtual-dom": "1.0.2" 22 | } 23 | }, 24 | "test-dependencies": { 25 | "direct": { 26 | "elm-explorations/test": "1.2.2" 27 | }, 28 | "indirect": { 29 | "elm/random": "1.0.0" 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /chapter-4/4.7-easier-code-organization/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-4/4.7-easier-code-organization/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /chapter-4/4.7-easier-code-organization/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-4/4.7-easier-code-organization/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-4/4.8-fuzz-testing/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0", 13 | "elm/json": "1.1.3", 14 | "elm/regex": "1.0.0" 15 | }, 16 | "indirect": { 17 | "elm/bytes": "1.0.8", 18 | "elm/file": "1.0.5", 19 | "elm/time": "1.0.0", 20 | "elm/url": "1.0.0", 21 | "elm/virtual-dom": "1.0.2" 22 | } 23 | }, 24 | "test-dependencies": { 25 | "direct": { 26 | "elm-explorations/test": "1.2.2" 27 | }, 28 | "indirect": { 29 | "elm/random": "1.0.0" 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /chapter-4/4.8-fuzz-testing/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | 6 | // Reject non-list type inputs 7 | if (Array.isArray(scores) === false) { 8 | throw new Error("Input must be of type array"); 9 | } 10 | 11 | var newScores = []; 12 | 13 | for (var i = 0; i < scores.length; i++) { 14 | 15 | // Reject arrays that contain values that are not numbers 16 | if (typeof scores[i] !== "number") { 17 | throw new Error("Input array must contain numbers only"); 18 | } 19 | else { 20 | newScores[i] = scores[i] * scoreMultiplier; 21 | } 22 | } 23 | 24 | return newScores; 25 | } 26 | 27 | 28 | function scoresLessThan320(scores) { 29 | return scores.filter(isLessThan320); 30 | } 31 | 32 | function isLessThan320(score) { 33 | return score < 320; 34 | } 35 | -------------------------------------------------------------------------------- /chapter-4/4.8-fuzz-testing/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-4/4.8-fuzz-testing/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /chapter-4/4.8-fuzz-testing/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-4/4.8-fuzz-testing/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-4/4.9-pattern-matching/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0", 13 | "elm/json": "1.1.3", 14 | "elm/regex": "1.0.0" 15 | }, 16 | "indirect": { 17 | "elm/bytes": "1.0.8", 18 | "elm/file": "1.0.5", 19 | "elm/time": "1.0.0", 20 | "elm/url": "1.0.0", 21 | "elm/virtual-dom": "1.0.2" 22 | } 23 | }, 24 | "test-dependencies": { 25 | "direct": { 26 | "elm-explorations/test": "1.2.2" 27 | }, 28 | "indirect": { 29 | "elm/random": "1.0.0" 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /chapter-4/4.9-pattern-matching/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | 6 | // Reject non-list type inputs 7 | if (Array.isArray(scores) === false) { 8 | throw new Error("Input must be of type array"); 9 | } 10 | 11 | var newScores = []; 12 | 13 | for (var i = 0; i < scores.length; i++) { 14 | 15 | // Reject arrays that contain values that are not numbers 16 | if (typeof scores[i] !== "number") { 17 | throw new Error("Input array must contain numbers only"); 18 | } 19 | else { 20 | newScores[i] = scores[i] * scoreMultiplier; 21 | } 22 | } 23 | 24 | return newScores; 25 | } 26 | 27 | 28 | function scoresLessThan320(scores) { 29 | return scores.filter(isLessThan320); 30 | } 31 | 32 | function isLessThan320(score) { 33 | return score < 320; 34 | } 35 | -------------------------------------------------------------------------------- /chapter-4/4.9-pattern-matching/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-4/4.9-pattern-matching/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /chapter-4/4.9-pattern-matching/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-4/4.9-pattern-matching/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-5/5.2-model-view-update-part-1/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0", 13 | "elm/json": "1.1.3", 14 | "elm/regex": "1.0.0" 15 | }, 16 | "indirect": { 17 | "elm/bytes": "1.0.8", 18 | "elm/file": "1.0.5", 19 | "elm/time": "1.0.0", 20 | "elm/url": "1.0.0", 21 | "elm/virtual-dom": "1.0.2" 22 | } 23 | }, 24 | "test-dependencies": { 25 | "direct": { 26 | "elm-explorations/test": "1.2.2" 27 | }, 28 | "indirect": { 29 | "elm/random": "1.0.0" 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /chapter-5/5.2-model-view-update-part-1/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-5/5.2-model-view-update-part-1/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /chapter-5/5.2-model-view-update-part-1/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-5/5.2-model-view-update-part-1/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-5/5.3-virtual-dom/beginning-elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.1", 10 | "elm/core": "1.0.2", 11 | "elm/html": "1.0.0", 12 | "elm/http": "2.0.0", 13 | "elm/json": "1.1.3", 14 | "elm/regex": "1.0.0" 15 | }, 16 | "indirect": { 17 | "elm/bytes": "1.0.8", 18 | "elm/file": "1.0.5", 19 | "elm/time": "1.0.0", 20 | "elm/url": "1.0.0", 21 | "elm/virtual-dom": "1.0.2" 22 | } 23 | }, 24 | "test-dependencies": { 25 | "direct": { 26 | "elm-explorations/test": "1.2.2" 27 | }, 28 | "indirect": { 29 | "elm/random": "1.0.0" 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /chapter-5/5.3-virtual-dom/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | 6 | // Reject non-list type inputs 7 | if (Array.isArray(scores) === false) { 8 | throw new Error("Input must be of type array"); 9 | } 10 | 11 | var newScores = []; 12 | 13 | for (var i = 0; i < scores.length; i++) { 14 | 15 | // Reject arrays that contain values that are not numbers 16 | if (typeof scores[i] !== "number") { 17 | throw new Error("Input array must contain numbers only"); 18 | } 19 | else { 20 | newScores[i] = scores[i] * scoreMultiplier; 21 | } 22 | } 23 | 24 | return newScores; 25 | } 26 | 27 | 28 | function scoresLessThan320(scores) { 29 | return scores.filter(isLessThan320); 30 | } 31 | 32 | function isLessThan320(score) { 33 | return score < 320; 34 | } 35 | -------------------------------------------------------------------------------- /chapter-5/5.3-virtual-dom/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-5/5.3-virtual-dom/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /chapter-5/5.3-virtual-dom/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-5/5.3-virtual-dom/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-5/5.4-model-view-update-part-2/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-5/5.4-model-view-update-part-2/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /chapter-5/5.4-model-view-update-part-2/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-5/5.4-model-view-update-part-2/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-5/5.4-model-view-update-part-2/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-5/5.4-model-view-update-part-2/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-5/5.6-commands/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | 6 | // Reject non-list type inputs 7 | if (Array.isArray(scores) === false) { 8 | throw new Error("Input must be of type array"); 9 | } 10 | 11 | var newScores = []; 12 | 13 | for (var i = 0; i < scores.length; i++) { 14 | 15 | // Reject arrays that contain values that are not numbers 16 | if (typeof scores[i] !== "number") { 17 | throw new Error("Input array must contain numbers only"); 18 | } 19 | else { 20 | newScores[i] = scores[i] * scoreMultiplier; 21 | } 22 | } 23 | 24 | return newScores; 25 | } 26 | 27 | 28 | function scoresLessThan320(scores) { 29 | return scores.filter(isLessThan320); 30 | } 31 | 32 | function isLessThan320(score) { 33 | return score < 320; 34 | } 35 | -------------------------------------------------------------------------------- /chapter-5/5.6-commands/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-5/5.6-commands/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /chapter-5/5.6-commands/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-5/5.6-commands/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-5/5.6-commands/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-5/5.6-commands/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-5/5.6-commands/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-6/6.2-fetching-data-using-get/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-6/6.2-fetching-data-using-get/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /chapter-6/6.2-fetching-data-using-get/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-6/6.2-fetching-data-using-get/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-6/6.2-fetching-data-using-get/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-6/6.2-fetching-data-using-get/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-6/6.2-fetching-data-using-get/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-6/6.2-fetching-data-using-get/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-6/6.3-decoding-json-part-1/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | 6 | // Reject non-list type inputs 7 | if (Array.isArray(scores) === false) { 8 | throw new Error("Input must be of type array"); 9 | } 10 | 11 | var newScores = []; 12 | 13 | for (var i = 0; i < scores.length; i++) { 14 | 15 | // Reject arrays that contain values that are not numbers 16 | if (typeof scores[i] !== "number") { 17 | throw new Error("Input array must contain numbers only"); 18 | } 19 | else { 20 | newScores[i] = scores[i] * scoreMultiplier; 21 | } 22 | } 23 | 24 | return newScores; 25 | } 26 | 27 | 28 | function scoresLessThan320(scores) { 29 | return scores.filter(isLessThan320); 30 | } 31 | 32 | function isLessThan320(score) { 33 | return score < 320; 34 | } 35 | -------------------------------------------------------------------------------- /chapter-6/6.3-decoding-json-part-1/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-6/6.3-decoding-json-part-1/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /chapter-6/6.3-decoding-json-part-1/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 1, 5 | "title": "json-server", 6 | "author": "typicode" 7 | }, 8 | { 9 | "id": 2, 10 | "title": "http-server", 11 | "author": "indexzero" 12 | } 13 | ], 14 | "comments": [ 15 | { 16 | "id": 1, 17 | "body": "some comment", 18 | "postId": 1 19 | } 20 | ], 21 | "profile": { 22 | "name": "typicode" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /chapter-6/6.3-decoding-json-part-1/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-6/6.3-decoding-json-part-1/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-6/6.3-decoding-json-part-1/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-6/6.3-decoding-json-part-1/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-6/6.3-decoding-json-part-1/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-6/6.3-decoding-json-part-1/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-6/6.3-decoding-json-part-1/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-6/6.4-decoding-json-part-2/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | 6 | // Reject non-list type inputs 7 | if (Array.isArray(scores) === false) { 8 | throw new Error("Input must be of type array"); 9 | } 10 | 11 | var newScores = []; 12 | 13 | for (var i = 0; i < scores.length; i++) { 14 | 15 | // Reject arrays that contain values that are not numbers 16 | if (typeof scores[i] !== "number") { 17 | throw new Error("Input array must contain numbers only"); 18 | } 19 | else { 20 | newScores[i] = scores[i] * scoreMultiplier; 21 | } 22 | } 23 | 24 | return newScores; 25 | } 26 | 27 | 28 | function scoresLessThan320(scores) { 29 | return scores.filter(isLessThan320); 30 | } 31 | 32 | function isLessThan320(score) { 33 | return score < 320; 34 | } 35 | -------------------------------------------------------------------------------- /chapter-6/6.4-decoding-json-part-2/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-6/6.4-decoding-json-part-2/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /chapter-6/6.4-decoding-json-part-2/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 1, 5 | "title": "json-server", 6 | "authorName": "typicode", 7 | "authorUrl": "https://github.com/typicode" 8 | }, 9 | { 10 | "id": 2, 11 | "title": "http-server", 12 | "authorName": "indexzero", 13 | "authorUrl": "https://github.com/indexzero" 14 | } 15 | ], 16 | "comments": [ 17 | { 18 | "id": 1, 19 | "body": "some comment", 20 | "postId": 1 21 | } 22 | ], 23 | "profile": { 24 | "name": "typicode" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /chapter-6/6.4-decoding-json-part-2/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-6/6.4-decoding-json-part-2/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-6/6.4-decoding-json-part-2/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-6/6.4-decoding-json-part-2/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-6/6.4-decoding-json-part-2/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-6/6.4-decoding-json-part-2/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-6/6.4-decoding-json-part-2/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-6/6.5-remote-data/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | 6 | // Reject non-list type inputs 7 | if (Array.isArray(scores) === false) { 8 | throw new Error("Input must be of type array"); 9 | } 10 | 11 | var newScores = []; 12 | 13 | for (var i = 0; i < scores.length; i++) { 14 | 15 | // Reject arrays that contain values that are not numbers 16 | if (typeof scores[i] !== "number") { 17 | throw new Error("Input array must contain numbers only"); 18 | } 19 | else { 20 | newScores[i] = scores[i] * scoreMultiplier; 21 | } 22 | } 23 | 24 | return newScores; 25 | } 26 | 27 | 28 | function scoresLessThan320(scores) { 29 | return scores.filter(isLessThan320); 30 | } 31 | 32 | function isLessThan320(score) { 33 | return score < 320; 34 | } 35 | -------------------------------------------------------------------------------- /chapter-6/6.5-remote-data/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-6/6.5-remote-data/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /chapter-6/6.5-remote-data/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 1, 5 | "title": "json-server", 6 | "authorName": "typicode", 7 | "authorUrl": "https://github.com/typicode" 8 | }, 9 | { 10 | "id": 2, 11 | "title": "http-server", 12 | "authorName": "indexzero", 13 | "authorUrl": "https://github.com/indexzero" 14 | } 15 | ], 16 | "comments": [ 17 | { 18 | "id": 1, 19 | "body": "some comment", 20 | "postId": 1 21 | } 22 | ], 23 | "profile": { 24 | "name": "typicode" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /chapter-6/6.5-remote-data/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-6/6.5-remote-data/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-6/6.5-remote-data/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-6/6.5-remote-data/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-6/6.5-remote-data/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-6/6.5-remote-data/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-6/6.5-remote-data/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-6/6.6-retrieving-data-on-initialization/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-6/6.6-retrieving-data-on-initialization/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /chapter-6/6.6-retrieving-data-on-initialization/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 1, 5 | "title": "json-server", 6 | "authorName": "typicode", 7 | "authorUrl": "https://github.com/typicode" 8 | }, 9 | { 10 | "id": 2, 11 | "title": "http-server", 12 | "authorName": "indexzero", 13 | "authorUrl": "https://github.com/indexzero" 14 | } 15 | ], 16 | "comments": [ 17 | { 18 | "id": 1, 19 | "body": "some comment", 20 | "postId": 1 21 | } 22 | ], 23 | "profile": { 24 | "name": "typicode" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /chapter-6/6.6-retrieving-data-on-initialization/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-6/6.6-retrieving-data-on-initialization/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-6/6.6-retrieving-data-on-initialization/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-6/6.6-retrieving-data-on-initialization/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-6/6.6-retrieving-data-on-initialization/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-6/6.6-retrieving-data-on-initialization/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-6/6.6-retrieving-data-on-initialization/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-7/7.4-creating-post-module/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | 6 | // Reject non-list type inputs 7 | if (Array.isArray(scores) === false) { 8 | throw new Error("Input must be of type array"); 9 | } 10 | 11 | var newScores = []; 12 | 13 | for (var i = 0; i < scores.length; i++) { 14 | 15 | // Reject arrays that contain values that are not numbers 16 | if (typeof scores[i] !== "number") { 17 | throw new Error("Input array must contain numbers only"); 18 | } 19 | else { 20 | newScores[i] = scores[i] * scoreMultiplier; 21 | } 22 | } 23 | 24 | return newScores; 25 | } 26 | 27 | 28 | function scoresLessThan320(scores) { 29 | return scores.filter(isLessThan320); 30 | } 31 | 32 | function isLessThan320(score) { 33 | return score < 320; 34 | } 35 | -------------------------------------------------------------------------------- /chapter-7/7.4-creating-post-module/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-7/7.4-creating-post-module/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /chapter-7/7.4-creating-post-module/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 1, 5 | "title": "json-server", 6 | "authorName": "typicode", 7 | "authorUrl": "https://github.com/typicode" 8 | }, 9 | { 10 | "id": 2, 11 | "title": "http-server", 12 | "authorName": "indexzero", 13 | "authorUrl": "https://github.com/indexzero" 14 | } 15 | ], 16 | "comments": [ 17 | { 18 | "id": 1, 19 | "body": "some comment", 20 | "postId": 1 21 | } 22 | ], 23 | "profile": { 24 | "name": "typicode" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /chapter-7/7.4-creating-post-module/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-7/7.4-creating-post-module/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-7/7.4-creating-post-module/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-7/7.4-creating-post-module/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-7/7.4-creating-post-module/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-7/7.4-creating-post-module/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-7/7.4-creating-post-module/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-7/7.5-creating-list-posts-page/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-7/7.5-creating-list-posts-page/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /chapter-7/7.5-creating-list-posts-page/beginning-elm/post-app/Main.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (main) 2 | 3 | import Browser 4 | import Page.ListPosts as ListPosts 5 | 6 | 7 | main : Program () ListPosts.Model ListPosts.Msg 8 | main = 9 | Browser.element 10 | { init = ListPosts.init 11 | , view = ListPosts.view 12 | , update = ListPosts.update 13 | , subscriptions = \_ -> Sub.none 14 | } 15 | -------------------------------------------------------------------------------- /chapter-7/7.5-creating-list-posts-page/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 1, 5 | "title": "json-server", 6 | "authorName": "typicode", 7 | "authorUrl": "https://github.com/typicode" 8 | }, 9 | { 10 | "id": 2, 11 | "title": "http-server", 12 | "authorName": "indexzero", 13 | "authorUrl": "https://github.com/indexzero" 14 | } 15 | ], 16 | "comments": [ 17 | { 18 | "id": 1, 19 | "body": "some comment", 20 | "postId": 1 21 | } 22 | ], 23 | "profile": { 24 | "name": "typicode" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /chapter-7/7.5-creating-list-posts-page/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-7/7.5-creating-list-posts-page/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-7/7.5-creating-list-posts-page/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-7/7.5-creating-list-posts-page/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-7/7.5-creating-list-posts-page/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-7/7.5-creating-list-posts-page/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-7/7.5-creating-list-posts-page/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-7/7.6-navigating-to-list-posts-page/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-7/7.6-navigating-to-list-posts-page/beginning-elm/post-app/Route.elm: -------------------------------------------------------------------------------- 1 | module Route exposing (Route(..), parseUrl) 2 | 3 | import Url exposing (Url) 4 | import Url.Parser exposing (..) 5 | 6 | 7 | type Route 8 | = NotFound 9 | | Posts 10 | 11 | 12 | parseUrl : Url -> Route 13 | parseUrl url = 14 | case parse matchRoute url of 15 | Just route -> 16 | route 17 | 18 | Nothing -> 19 | NotFound 20 | 21 | 22 | matchRoute : Parser (Route -> a) a 23 | matchRoute = 24 | oneOf 25 | [ map Posts top 26 | , map Posts (s "posts") 27 | ] 28 | -------------------------------------------------------------------------------- /chapter-7/7.6-navigating-to-list-posts-page/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 1, 5 | "title": "json-server", 6 | "authorName": "typicode", 7 | "authorUrl": "https://github.com/typicode" 8 | }, 9 | { 10 | "id": 2, 11 | "title": "http-server", 12 | "authorName": "indexzero", 13 | "authorUrl": "https://github.com/indexzero" 14 | } 15 | ], 16 | "comments": [ 17 | { 18 | "id": 1, 19 | "body": "some comment", 20 | "postId": 1 21 | } 22 | ], 23 | "profile": { 24 | "name": "typicode" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /chapter-7/7.6-navigating-to-list-posts-page/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-7/7.6-navigating-to-list-posts-page/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-7/7.6-navigating-to-list-posts-page/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-7/7.6-navigating-to-list-posts-page/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-7/7.6-navigating-to-list-posts-page/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-7/7.6-navigating-to-list-posts-page/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-7/7.6-navigating-to-list-posts-page/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-7/7.7-editing-a-post/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | 6 | // Reject non-list type inputs 7 | if (Array.isArray(scores) === false) { 8 | throw new Error("Input must be of type array"); 9 | } 10 | 11 | var newScores = []; 12 | 13 | for (var i = 0; i < scores.length; i++) { 14 | 15 | // Reject arrays that contain values that are not numbers 16 | if (typeof scores[i] !== "number") { 17 | throw new Error("Input array must contain numbers only"); 18 | } 19 | else { 20 | newScores[i] = scores[i] * scoreMultiplier; 21 | } 22 | } 23 | 24 | return newScores; 25 | } 26 | 27 | 28 | function scoresLessThan320(scores) { 29 | return scores.filter(isLessThan320); 30 | } 31 | 32 | function isLessThan320(score) { 33 | return score < 320; 34 | } 35 | -------------------------------------------------------------------------------- /chapter-7/7.7-editing-a-post/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-7/7.7-editing-a-post/beginning-elm/post-app/Error.elm: -------------------------------------------------------------------------------- 1 | module Error exposing (buildErrorMessage) 2 | 3 | import Http 4 | 5 | 6 | buildErrorMessage : Http.Error -> String 7 | buildErrorMessage httpError = 8 | case httpError of 9 | Http.BadUrl message -> 10 | message 11 | 12 | Http.Timeout -> 13 | "Server is taking too long to respond. Please try again later." 14 | 15 | Http.NetworkError -> 16 | "Unable to reach server." 17 | 18 | Http.BadStatus statusCode -> 19 | "Request failed with status code: " ++ String.fromInt statusCode 20 | 21 | Http.BadBody message -> 22 | message 23 | -------------------------------------------------------------------------------- /chapter-7/7.7-editing-a-post/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 1, 5 | "title": "json-server (modified)", 6 | "authorName": "typicode", 7 | "authorUrl": "https://github.com/typicode" 8 | }, 9 | { 10 | "id": 2, 11 | "title": "http-server", 12 | "authorName": "indexzero", 13 | "authorUrl": "https://github.com/indexzero" 14 | } 15 | ], 16 | "comments": [ 17 | { 18 | "id": 1, 19 | "body": "some comment", 20 | "postId": 1 21 | } 22 | ], 23 | "profile": { 24 | "name": "typicode" 25 | } 26 | } -------------------------------------------------------------------------------- /chapter-7/7.7-editing-a-post/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-7/7.7-editing-a-post/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-7/7.7-editing-a-post/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-7/7.7-editing-a-post/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-7/7.7-editing-a-post/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-7/7.7-editing-a-post/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-7/7.7-editing-a-post/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-7/7.8-deleting-a-post/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | 6 | // Reject non-list type inputs 7 | if (Array.isArray(scores) === false) { 8 | throw new Error("Input must be of type array"); 9 | } 10 | 11 | var newScores = []; 12 | 13 | for (var i = 0; i < scores.length; i++) { 14 | 15 | // Reject arrays that contain values that are not numbers 16 | if (typeof scores[i] !== "number") { 17 | throw new Error("Input array must contain numbers only"); 18 | } 19 | else { 20 | newScores[i] = scores[i] * scoreMultiplier; 21 | } 22 | } 23 | 24 | return newScores; 25 | } 26 | 27 | 28 | function scoresLessThan320(scores) { 29 | return scores.filter(isLessThan320); 30 | } 31 | 32 | function isLessThan320(score) { 33 | return score < 320; 34 | } 35 | -------------------------------------------------------------------------------- /chapter-7/7.8-deleting-a-post/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-7/7.8-deleting-a-post/beginning-elm/post-app/Error.elm: -------------------------------------------------------------------------------- 1 | module Error exposing (buildErrorMessage) 2 | 3 | import Http 4 | 5 | 6 | buildErrorMessage : Http.Error -> String 7 | buildErrorMessage httpError = 8 | case httpError of 9 | Http.BadUrl message -> 10 | message 11 | 12 | Http.Timeout -> 13 | "Server is taking too long to respond. Please try again later." 14 | 15 | Http.NetworkError -> 16 | "Unable to reach server." 17 | 18 | Http.BadStatus statusCode -> 19 | "Request failed with status code: " ++ String.fromInt statusCode 20 | 21 | Http.BadBody message -> 22 | message 23 | -------------------------------------------------------------------------------- /chapter-7/7.8-deleting-a-post/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 2, 5 | "title": "http-server", 6 | "authorName": "indexzero", 7 | "authorUrl": "https://github.com/indexzero" 8 | } 9 | ], 10 | "comments": [], 11 | "profile": { 12 | "name": "typicode" 13 | } 14 | } -------------------------------------------------------------------------------- /chapter-7/7.8-deleting-a-post/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-7/7.8-deleting-a-post/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-7/7.8-deleting-a-post/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-7/7.8-deleting-a-post/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-7/7.8-deleting-a-post/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-7/7.8-deleting-a-post/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-7/7.8-deleting-a-post/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-7/7.9-creating-a-new-post/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | 6 | // Reject non-list type inputs 7 | if (Array.isArray(scores) === false) { 8 | throw new Error("Input must be of type array"); 9 | } 10 | 11 | var newScores = []; 12 | 13 | for (var i = 0; i < scores.length; i++) { 14 | 15 | // Reject arrays that contain values that are not numbers 16 | if (typeof scores[i] !== "number") { 17 | throw new Error("Input array must contain numbers only"); 18 | } 19 | else { 20 | newScores[i] = scores[i] * scoreMultiplier; 21 | } 22 | } 23 | 24 | return newScores; 25 | } 26 | 27 | 28 | function scoresLessThan320(scores) { 29 | return scores.filter(isLessThan320); 30 | } 31 | 32 | function isLessThan320(score) { 33 | return score < 320; 34 | } 35 | -------------------------------------------------------------------------------- /chapter-7/7.9-creating-a-new-post/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-7/7.9-creating-a-new-post/beginning-elm/post-app/Error.elm: -------------------------------------------------------------------------------- 1 | module Error exposing (buildErrorMessage) 2 | 3 | import Http 4 | 5 | 6 | buildErrorMessage : Http.Error -> String 7 | buildErrorMessage httpError = 8 | case httpError of 9 | Http.BadUrl message -> 10 | message 11 | 12 | Http.Timeout -> 13 | "Server is taking too long to respond. Please try again later." 14 | 15 | Http.NetworkError -> 16 | "Unable to reach server." 17 | 18 | Http.BadStatus statusCode -> 19 | "Request failed with status code: " ++ String.fromInt statusCode 20 | 21 | Http.BadBody message -> 22 | message 23 | -------------------------------------------------------------------------------- /chapter-7/7.9-creating-a-new-post/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 2, 5 | "title": "http-server", 6 | "authorName": "indexzero", 7 | "authorUrl": "https://github.com/indexzero" 8 | }, 9 | { 10 | "title": "elm-live", 11 | "authorName": "wking-io", 12 | "authorUrl": "https://github.com/wking-io", 13 | "id": 3 14 | } 15 | ], 16 | "comments": [], 17 | "profile": { 18 | "name": "typicode" 19 | } 20 | } -------------------------------------------------------------------------------- /chapter-7/7.9-creating-a-new-post/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-7/7.9-creating-a-new-post/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-7/7.9-creating-a-new-post/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-7/7.9-creating-a-new-post/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-7/7.9-creating-a-new-post/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-7/7.9-creating-a-new-post/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-7/7.9-creating-a-new-post/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-8/8.2-sending-data-to-javascript/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-8/8.2-sending-data-to-javascript/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-8/8.2-sending-data-to-javascript/beginning-elm/post-app/Error.elm: -------------------------------------------------------------------------------- 1 | module Error exposing (buildErrorMessage) 2 | 3 | import Http 4 | 5 | 6 | buildErrorMessage : Http.Error -> String 7 | buildErrorMessage httpError = 8 | case httpError of 9 | Http.BadUrl message -> 10 | message 11 | 12 | Http.Timeout -> 13 | "Server is taking too long to respond. Please try again later." 14 | 15 | Http.NetworkError -> 16 | "Unable to reach server." 17 | 18 | Http.BadStatus statusCode -> 19 | "Request failed with status code: " ++ String.fromInt statusCode 20 | 21 | Http.BadBody message -> 22 | message 23 | -------------------------------------------------------------------------------- /chapter-8/8.2-sending-data-to-javascript/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 2, 5 | "title": "http-server", 6 | "authorName": "indexzero", 7 | "authorUrl": "https://github.com/indexzero" 8 | }, 9 | { 10 | "title": "elm-live", 11 | "authorName": "wking-io", 12 | "authorUrl": "https://github.com/wking-io", 13 | "id": 3 14 | } 15 | ], 16 | "comments": [], 17 | "profile": { 18 | "name": "typicode" 19 | } 20 | } -------------------------------------------------------------------------------- /chapter-8/8.2-sending-data-to-javascript/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-8/8.2-sending-data-to-javascript/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-8/8.2-sending-data-to-javascript/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-8/8.2-sending-data-to-javascript/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-8/8.2-sending-data-to-javascript/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-8/8.2-sending-data-to-javascript/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-8/8.2-sending-data-to-javascript/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-8/8.3-subscriptions/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | 6 | // Reject non-list type inputs 7 | if (Array.isArray(scores) === false) { 8 | throw new Error("Input must be of type array"); 9 | } 10 | 11 | var newScores = []; 12 | 13 | for (var i = 0; i < scores.length; i++) { 14 | 15 | // Reject arrays that contain values that are not numbers 16 | if (typeof scores[i] !== "number") { 17 | throw new Error("Input array must contain numbers only"); 18 | } 19 | else { 20 | newScores[i] = scores[i] * scoreMultiplier; 21 | } 22 | } 23 | 24 | return newScores; 25 | } 26 | 27 | 28 | function scoresLessThan320(scores) { 29 | return scores.filter(isLessThan320); 30 | } 31 | 32 | function isLessThan320(score) { 33 | return score < 320; 34 | } 35 | -------------------------------------------------------------------------------- /chapter-8/8.3-subscriptions/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-8/8.3-subscriptions/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-8/8.3-subscriptions/beginning-elm/post-app/Error.elm: -------------------------------------------------------------------------------- 1 | module Error exposing (buildErrorMessage) 2 | 3 | import Http 4 | 5 | 6 | buildErrorMessage : Http.Error -> String 7 | buildErrorMessage httpError = 8 | case httpError of 9 | Http.BadUrl message -> 10 | message 11 | 12 | Http.Timeout -> 13 | "Server is taking too long to respond. Please try again later." 14 | 15 | Http.NetworkError -> 16 | "Unable to reach server." 17 | 18 | Http.BadStatus statusCode -> 19 | "Request failed with status code: " ++ String.fromInt statusCode 20 | 21 | Http.BadBody message -> 22 | message 23 | -------------------------------------------------------------------------------- /chapter-8/8.3-subscriptions/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 2, 5 | "title": "http-server", 6 | "authorName": "indexzero", 7 | "authorUrl": "https://github.com/indexzero" 8 | }, 9 | { 10 | "title": "elm-live", 11 | "authorName": "wking-io", 12 | "authorUrl": "https://github.com/wking-io", 13 | "id": 3 14 | } 15 | ], 16 | "comments": [], 17 | "profile": { 18 | "name": "typicode" 19 | } 20 | } -------------------------------------------------------------------------------- /chapter-8/8.3-subscriptions/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-8/8.3-subscriptions/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-8/8.3-subscriptions/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-8/8.3-subscriptions/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-8/8.3-subscriptions/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-8/8.3-subscriptions/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-8/8.3-subscriptions/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-8/8.4-receiving-data-from-javascript/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-8/8.4-receiving-data-from-javascript/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /chapter-8/8.4-receiving-data-from-javascript/beginning-elm/post-app/Error.elm: -------------------------------------------------------------------------------- 1 | module Error exposing (buildErrorMessage) 2 | 3 | import Http 4 | 5 | 6 | buildErrorMessage : Http.Error -> String 7 | buildErrorMessage httpError = 8 | case httpError of 9 | Http.BadUrl message -> 10 | message 11 | 12 | Http.Timeout -> 13 | "Server is taking too long to respond. Please try again later." 14 | 15 | Http.NetworkError -> 16 | "Unable to reach server." 17 | 18 | Http.BadStatus statusCode -> 19 | "Request failed with status code: " ++ String.fromInt statusCode 20 | 21 | Http.BadBody message -> 22 | message 23 | -------------------------------------------------------------------------------- /chapter-8/8.4-receiving-data-from-javascript/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 2, 5 | "title": "http-server", 6 | "authorName": "indexzero", 7 | "authorUrl": "https://github.com/indexzero" 8 | }, 9 | { 10 | "title": "elm-live", 11 | "authorName": "wking-io", 12 | "authorUrl": "https://github.com/wking-io", 13 | "id": 3 14 | } 15 | ], 16 | "comments": [], 17 | "profile": { 18 | "name": "typicode" 19 | } 20 | } -------------------------------------------------------------------------------- /chapter-8/8.4-receiving-data-from-javascript/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-8/8.4-receiving-data-from-javascript/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-8/8.4-receiving-data-from-javascript/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-8/8.4-receiving-data-from-javascript/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-8/8.4-receiving-data-from-javascript/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-8/8.4-receiving-data-from-javascript/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-8/8.4-receiving-data-from-javascript/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-8/8.5-protecting-boundaries/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-8/8.5-protecting-boundaries/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /chapter-8/8.5-protecting-boundaries/beginning-elm/post-app/Error.elm: -------------------------------------------------------------------------------- 1 | module Error exposing (buildErrorMessage) 2 | 3 | import Http 4 | 5 | 6 | buildErrorMessage : Http.Error -> String 7 | buildErrorMessage httpError = 8 | case httpError of 9 | Http.BadUrl message -> 10 | message 11 | 12 | Http.Timeout -> 13 | "Server is taking too long to respond. Please try again later." 14 | 15 | Http.NetworkError -> 16 | "Unable to reach server." 17 | 18 | Http.BadStatus statusCode -> 19 | "Request failed with status code: " ++ String.fromInt statusCode 20 | 21 | Http.BadBody message -> 22 | message 23 | -------------------------------------------------------------------------------- /chapter-8/8.5-protecting-boundaries/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 2, 5 | "title": "http-server", 6 | "authorName": "indexzero", 7 | "authorUrl": "https://github.com/indexzero" 8 | }, 9 | { 10 | "title": "elm-live", 11 | "authorName": "wking-io", 12 | "authorUrl": "https://github.com/wking-io", 13 | "id": 3 14 | } 15 | ], 16 | "comments": [], 17 | "profile": { 18 | "name": "typicode" 19 | } 20 | } -------------------------------------------------------------------------------- /chapter-8/8.5-protecting-boundaries/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-8/8.5-protecting-boundaries/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-8/8.5-protecting-boundaries/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-8/8.5-protecting-boundaries/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-8/8.5-protecting-boundaries/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-8/8.5-protecting-boundaries/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-8/8.5-protecting-boundaries/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-8/8.6-saving-app-state/beginning-elm/experiment.js: -------------------------------------------------------------------------------- 1 | var scoreMultiplier = 2; 2 | var highestScores = [316, 320, 312, 370, 337, 318, 314]; 3 | 4 | function doubleScores(scores) { 5 | 6 | // Reject non-list type inputs 7 | if (Array.isArray(scores) === false) { 8 | throw new Error("Input must be of type array"); 9 | } 10 | 11 | var newScores = []; 12 | 13 | for (var i = 0; i < scores.length; i++) { 14 | 15 | // Reject arrays that contain values that are not numbers 16 | if (typeof scores[i] !== "number") { 17 | throw new Error("Input array must contain numbers only"); 18 | } 19 | else { 20 | newScores[i] = scores[i] * scoreMultiplier; 21 | } 22 | } 23 | 24 | return newScores; 25 | } 26 | 27 | 28 | function scoresLessThan320(scores) { 29 | return scores.filter(isLessThan320); 30 | } 31 | 32 | function isLessThan320(score) { 33 | return score < 320; 34 | } 35 | -------------------------------------------------------------------------------- /chapter-8/8.6-saving-app-state/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-8/8.6-saving-app-state/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-8/8.6-saving-app-state/beginning-elm/post-app/Error.elm: -------------------------------------------------------------------------------- 1 | module Error exposing (buildErrorMessage) 2 | 3 | import Http 4 | 5 | 6 | buildErrorMessage : Http.Error -> String 7 | buildErrorMessage httpError = 8 | case httpError of 9 | Http.BadUrl message -> 10 | message 11 | 12 | Http.Timeout -> 13 | "Server is taking too long to respond. Please try again later." 14 | 15 | Http.NetworkError -> 16 | "Unable to reach server." 17 | 18 | Http.BadStatus statusCode -> 19 | "Request failed with status code: " ++ String.fromInt statusCode 20 | 21 | Http.BadBody message -> 22 | message 23 | -------------------------------------------------------------------------------- /chapter-8/8.6-saving-app-state/beginning-elm/post-app/Ports.elm: -------------------------------------------------------------------------------- 1 | port module Ports exposing (storePosts) 2 | 3 | 4 | port storePosts : String -> Cmd msg 5 | -------------------------------------------------------------------------------- /chapter-8/8.6-saving-app-state/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 2, 5 | "title": "http-server", 6 | "authorName": "indexzero", 7 | "authorUrl": "https://github.com/indexzero" 8 | }, 9 | { 10 | "title": "elm-live", 11 | "authorName": "wking-io", 12 | "authorUrl": "https://github.com/wking-io", 13 | "id": 3 14 | } 15 | ], 16 | "comments": [], 17 | "profile": { 18 | "name": "typicode" 19 | } 20 | } -------------------------------------------------------------------------------- /chapter-8/8.6-saving-app-state/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-8/8.6-saving-app-state/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-8/8.6-saving-app-state/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-8/8.6-saving-app-state/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-8/8.6-saving-app-state/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-8/8.6-saving-app-state/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-8/8.6-saving-app-state/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-8/8.7-retrieving-app-state/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-8/8.7-retrieving-app-state/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /chapter-8/8.7-retrieving-app-state/beginning-elm/post-app/Error.elm: -------------------------------------------------------------------------------- 1 | module Error exposing (buildErrorMessage) 2 | 3 | import Http 4 | 5 | 6 | buildErrorMessage : Http.Error -> String 7 | buildErrorMessage httpError = 8 | case httpError of 9 | Http.BadUrl message -> 10 | message 11 | 12 | Http.Timeout -> 13 | "Server is taking too long to respond. Please try again later." 14 | 15 | Http.NetworkError -> 16 | "Unable to reach server." 17 | 18 | Http.BadStatus statusCode -> 19 | "Request failed with status code: " ++ String.fromInt statusCode 20 | 21 | Http.BadBody message -> 22 | message 23 | -------------------------------------------------------------------------------- /chapter-8/8.7-retrieving-app-state/beginning-elm/post-app/Ports.elm: -------------------------------------------------------------------------------- 1 | port module Ports exposing (storePosts) 2 | 3 | 4 | port storePosts : String -> Cmd msg 5 | -------------------------------------------------------------------------------- /chapter-8/8.7-retrieving-app-state/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 2, 5 | "title": "http-server", 6 | "authorName": "indexzero", 7 | "authorUrl": "https://github.com/indexzero" 8 | }, 9 | { 10 | "title": "elm-live", 11 | "authorName": "wking-io", 12 | "authorUrl": "https://github.com/wking-io", 13 | "id": 3 14 | } 15 | ], 16 | "comments": [], 17 | "profile": { 18 | "name": "typicode" 19 | } 20 | } -------------------------------------------------------------------------------- /chapter-8/8.7-retrieving-app-state/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-8/8.7-retrieving-app-state/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-8/8.7-retrieving-app-state/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-8/8.7-retrieving-app-state/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-8/8.7-retrieving-app-state/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-8/8.7-retrieving-app-state/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-8/8.7-retrieving-app-state/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/assets/images/waterfall.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pawanpoudel/beginning-elm-code/e7aaf20d6f6e37dbc4277bf365c6b564b209a2c0/chapter-8/8.8-interacting-with-web-components/beginning-elm/assets/images/waterfall.jpg -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 14 | 15 | 16 |
17 |

Welcome to Dunder Mifflin!

18 |

19 | Dunder Mifflin Inc. (stock symbol DMI) is 20 | a micro-cap regional paper and office supply distributor with 21 | an emphasis on servicing small-business clients. 22 |

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 12 | 13 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/node_modules/@github/image-crop-element/dist/index.esm.js.flow: -------------------------------------------------------------------------------- 1 | /* @flow strict */ 2 | 3 | declare module '@github/image-crop-element' { 4 | declare export default class ImageCropElement extends HTMLElement { 5 | get src(): ?string; 6 | set src(val: ?string): void; 7 | get loaded(): boolean; 8 | set loaded(val: boolean): void; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/node_modules/@github/image-crop-element/dist/index.umd.js.flow: -------------------------------------------------------------------------------- 1 | /* @flow strict */ 2 | 3 | declare module '@github/image-crop-element' { 4 | declare export default class ImageCropElement extends HTMLElement { 5 | get src(): ?string; 6 | set src(val: ?string): void; 7 | get loaded(): boolean; 8 | set loaded(val: boolean): void; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/node_modules/@github/image-crop-element/index.d.ts: -------------------------------------------------------------------------------- 1 | export default class ImageCropElement extends HTMLElement { 2 | src: string || null 3 | loaded: boolean 4 | } 5 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "beginning-elm", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@github/image-crop-element": { 8 | "version": "3.0.4", 9 | "resolved": "https://registry.npmjs.org/@github/image-crop-element/-/image-crop-element-3.0.4.tgz", 10 | "integrity": "sha512-/3ZKqYY9v/nRVA3jpXx2gZqUtHfCQUKfQmS+XyYO4+pHpFJf77wrVDRiBFeqLCXbE2K16mGkO4Tw+rjpFZW5wg==" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "beginning-elm", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "dom-performance-test.js", 6 | "directories": { 7 | "test": "tests" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1" 11 | }, 12 | "keywords": [], 13 | "author": "", 14 | "license": "ISC", 15 | "dependencies": { 16 | "@github/image-crop-element": "^3.0.4" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/post-app/Error.elm: -------------------------------------------------------------------------------- 1 | module Error exposing (buildErrorMessage) 2 | 3 | import Http 4 | 5 | 6 | buildErrorMessage : Http.Error -> String 7 | buildErrorMessage httpError = 8 | case httpError of 9 | Http.BadUrl message -> 10 | message 11 | 12 | Http.Timeout -> 13 | "Server is taking too long to respond. Please try again later." 14 | 15 | Http.NetworkError -> 16 | "Unable to reach server." 17 | 18 | Http.BadStatus statusCode -> 19 | "Request failed with status code: " ++ String.fromInt statusCode 20 | 21 | Http.BadBody message -> 22 | message 23 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/post-app/Ports.elm: -------------------------------------------------------------------------------- 1 | port module Ports exposing (storePosts) 2 | 3 | 4 | port storePosts : String -> Cmd msg 5 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "posts": [ 3 | { 4 | "id": 2, 5 | "title": "http-server", 6 | "authorName": "indexzero", 7 | "authorUrl": "https://github.com/indexzero" 8 | }, 9 | { 10 | "title": "elm-live", 11 | "authorName": "wking-io", 12 | "authorUrl": "https://github.com/wking-io", 13 | "id": 3 14 | } 15 | ], 16 | "comments": [], 17 | "profile": { 18 | "name": "typicode" 19 | } 20 | } -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/server/old-school.json: -------------------------------------------------------------------------------- 1 | { 2 | "nicknames" : ["The Godfather", "The Tank", "Beanie", "Cheese"] 3 | } 4 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/server/old-school.txt: -------------------------------------------------------------------------------- 1 | The Godfather, The Tank, Beanie, Cheese 2 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/signup-style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | padding-left: 3cm; 3 | } 4 | 5 | form { 6 | border-radius: 5px; 7 | background-color: #f2f2f2; 8 | padding: 20px; 9 | width: 300px; 10 | } 11 | 12 | input { 13 | display: block; 14 | width: 260px; 15 | padding: 12px 20px; 16 | margin: 8px 0; 17 | border: none; 18 | border-radius: 4px; 19 | } 20 | 21 | button { 22 | width: 300px; 23 | background-color: #397cd5; 24 | color: white; 25 | padding: 14px 20px; 26 | margin-top: 10px; 27 | border: none; 28 | border-radius: 4px; 29 | font-size: 16px; 30 | } 31 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/src/Asset.elm: -------------------------------------------------------------------------------- 1 | module Asset exposing (Image, src, waterfall) 2 | 3 | import Html exposing (Attribute) 4 | import Html.Attributes as Attr 5 | 6 | 7 | type Image 8 | = Image String 9 | 10 | 11 | 12 | -- IMAGES 13 | 14 | 15 | waterfall : Image 16 | waterfall = 17 | image "waterfall.jpg" 18 | 19 | 20 | image : String -> Image 21 | image filename = 22 | Image ("/assets/images/" ++ filename) 23 | 24 | 25 | 26 | -- USING IMAGES 27 | 28 | 29 | src : Image -> Attribute msg 30 | src (Image url) = 31 | Attr.src url 32 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/src/HomePage.elm: -------------------------------------------------------------------------------- 1 | module HomePage exposing (main) 2 | 3 | import Html exposing (..) 4 | import Html.Attributes exposing (..) 5 | 6 | 7 | view : a -> Html msg 8 | view model = 9 | div [ class "jumbotron" ] 10 | [ h1 [] [ text "Welcome to Dunder Mifflin!" ] 11 | , p [] 12 | [ text "Dunder Mifflin Inc. (stock symbol " 13 | , strong [] [ text "DMI" ] 14 | , text <| 15 | """ 16 | ) is a micro-cap regional paper and office 17 | supply distributor with an emphasis on servicing 18 | small-business clients. 19 | """ 20 | ] 21 | ] 22 | 23 | 24 | main : Html msg 25 | main = 26 | view "dummy model" 27 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/src/MyList.elm: -------------------------------------------------------------------------------- 1 | module MyList exposing (MyList(..), isEmpty, sum) 2 | 3 | 4 | type MyList a 5 | = Empty 6 | | Node a (MyList a) 7 | 8 | 9 | sum : MyList Int -> Int 10 | sum myList = 11 | case myList of 12 | Empty -> 13 | 0 14 | 15 | Node intValue remainingNodes -> 16 | intValue + sum remainingNodes 17 | 18 | 19 | isEmpty : MyList a -> Bool 20 | isEmpty xs = 21 | isItReallyEmpty xs 22 | 23 | 24 | isItReallyEmpty : MyList a -> Bool 25 | isItReallyEmpty xs = 26 | case xs of 27 | Empty -> 28 | True 29 | 30 | _ -> 31 | False 32 | -------------------------------------------------------------------------------- /chapter-8/8.8-interacting-with-web-components/beginning-elm/src/Profile.elm: -------------------------------------------------------------------------------- 1 | module Profile exposing (Name, createName) 2 | 3 | 4 | type Name 5 | = Name String String 6 | 7 | 8 | createName : String -> String -> Name 9 | createName firstName lastName = 10 | Name firstName lastName 11 | --------------------------------------------------------------------------------