├── .editorconfig
├── .gitignore
├── Makefile
├── app
├── 020_signals
│ ├── mailbox-flow.png
│ └── mailbox-flow.pu
├── 040_effects
│ ├── effects-v02.png
│ ├── effects-v03.png
│ ├── effects-v04.png
│ ├── effects-v05.png
│ ├── effects.dia
│ ├── effects.dia~
│ ├── effects.graphml
│ ├── tasks-v08.png
│ └── tasks.odg
├── 050_starting
│ ├── plan-v02.odg
│ ├── plan-v02.png
│ ├── plan-v03.odg
│ ├── plan-v03.png
│ ├── plan-v04.png
│ ├── plan-v05.png
│ ├── plan-v06.png
│ ├── plan.dia
│ ├── plan.dia~
│ ├── plan.graphml
│ ├── plan.odg
│ └── plan.png
├── 060_resources
│ └── screenshot.png
├── 070_routing
│ ├── router-v01.odg
│ ├── screenshot-edit-no-nav.png
│ └── screenshot.png
├── 075
│ └── screenshot-edit.png
├── 080_fetching_resources
│ ├── flow-v01.pu
│ ├── flow-v02.png
│ └── flow-v03.png
├── 090_showing_errors
│ ├── flow-v01.mdj
│ ├── flow-v01.pu
│ ├── flow-v05.png
│ └── screenshot.png
├── 100_adding_players
│ ├── flow-v01.png
│ ├── flow-v02.png
│ ├── flow-v03.png
│ ├── flow-v04.png
│ ├── flow.pu
│ └── screenshot.png
├── 110_deleting
│ ├── flow.png
│ ├── flow.pu
│ ├── screencast.gif
│ ├── screencast.mp4
│ ├── screenshot-confirm.png
│ └── screenshot-list.png
├── 120_edit
│ └── screenshot-level.png
├── elm.png
├── logo-v01.idraw
├── logo-v01.png
└── logo-v02.png
├── code
├── 010_foundations
│ ├── Hello.elm
│ └── TypeVariables.elm
├── 020_signals
│ ├── BasicMouse.elm
│ ├── BasicMouseDouble.elm
│ ├── Clicks.elm
│ ├── ClicksWithFoldp.elm
│ ├── Mailbox01.elm
│ └── Mailbox02.elm
├── 040_effects
│ ├── Effects.elm
│ ├── StartApp.elm
│ ├── Tasks01.elm
│ └── Tasks02.elm
├── C030ElmArch
│ ├── Actions.elm
│ ├── ActionsMultiple.elm
│ ├── ActionsWithPayload.elm
│ ├── Composing
│ │ ├── App.elm
│ │ ├── Widget.elm
│ │ ├── flow-v01.png
│ │ └── flow.pu
│ ├── Mailbox.elm
│ ├── Model.elm
│ ├── StartAppSimple.elm
│ └── Update.elm
├── elm-package.json
├── index.js
└── package.json
└── readme.md
/.editorconfig:
--------------------------------------------------------------------------------
1 | # top-most EditorConfig file
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 |
8 | [*.yml]
9 | indent_style = space
10 | indent_size = 2
11 |
12 | [Makefile]
13 | indent_style = tab
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | elm-stuff
4 | elm.js
5 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | pu:
2 | java -jar /usr/local/bin/plantuml.jar assets/020_signals/mailbox-flow.pu
3 |
4 | pu-composing:
5 | java -jar /usr/local/bin/plantuml.jar code/C030ElmArch/Composing/flow.pu
6 |
--------------------------------------------------------------------------------
/app/020_signals/mailbox-flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/020_signals/mailbox-flow.png
--------------------------------------------------------------------------------
/app/020_signals/mailbox-flow.pu:
--------------------------------------------------------------------------------
1 | @startuml
2 | participant mb
3 | participant main
4 | participant view
5 |
6 | main -> view : 1. address ""
7 | view --> main : 2. Rendered view
8 | view -> mb : 3. "Hello"
9 | mb -> main : 4. "Hello"
10 | main --> view : 5. address "Hello"
11 | view --> main : 6. Rendered view
12 | @enduml
13 |
--------------------------------------------------------------------------------
/app/040_effects/effects-v02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/040_effects/effects-v02.png
--------------------------------------------------------------------------------
/app/040_effects/effects-v03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/040_effects/effects-v03.png
--------------------------------------------------------------------------------
/app/040_effects/effects-v04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/040_effects/effects-v04.png
--------------------------------------------------------------------------------
/app/040_effects/effects-v05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/040_effects/effects-v05.png
--------------------------------------------------------------------------------
/app/040_effects/effects.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/040_effects/effects.dia
--------------------------------------------------------------------------------
/app/040_effects/effects.dia~:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/040_effects/effects.dia~
--------------------------------------------------------------------------------
/app/040_effects/effects.graphml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | modelAndFxSignal
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | modelSignal
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | main
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | oneActionAddress
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 | actionsMailbox.address
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 | 1
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 | view
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 | 3
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 | 2
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 | 4
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 | 5
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 | update
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 | 7
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 | 8
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 | fxSignal
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 | port
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 | 9
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 | taskSignal
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 | 10
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 | 11
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 | 12
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 | 13
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 | actionsMailbox.signal
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 | 6
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 | 14
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 | update
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 | 15
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 | 16
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 | view
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 | 17
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 |
814 |
815 |
816 |
817 |
818 |
819 |
820 |
821 |
822 |
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
832 |
833 |
834 |
835 |
836 |
837 |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 |
846 |
847 |
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 |
868 |
869 |
870 |
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 |
886 |
887 |
888 |
889 |
890 |
891 |
892 |
893 |
894 |
895 |
896 |
--------------------------------------------------------------------------------
/app/040_effects/tasks-v08.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/040_effects/tasks-v08.png
--------------------------------------------------------------------------------
/app/040_effects/tasks.odg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/040_effects/tasks.odg
--------------------------------------------------------------------------------
/app/050_starting/plan-v02.odg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/050_starting/plan-v02.odg
--------------------------------------------------------------------------------
/app/050_starting/plan-v02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/050_starting/plan-v02.png
--------------------------------------------------------------------------------
/app/050_starting/plan-v03.odg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/050_starting/plan-v03.odg
--------------------------------------------------------------------------------
/app/050_starting/plan-v03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/050_starting/plan-v03.png
--------------------------------------------------------------------------------
/app/050_starting/plan-v04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/050_starting/plan-v04.png
--------------------------------------------------------------------------------
/app/050_starting/plan-v05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/050_starting/plan-v05.png
--------------------------------------------------------------------------------
/app/050_starting/plan-v06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/050_starting/plan-v06.png
--------------------------------------------------------------------------------
/app/050_starting/plan.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/050_starting/plan.dia
--------------------------------------------------------------------------------
/app/050_starting/plan.dia~:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/050_starting/plan.dia~
--------------------------------------------------------------------------------
/app/050_starting/plan.graphml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | Players
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | Perks
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | Search
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | List
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | List
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 | Name
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 | Name
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 | Strengh
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 | Strengh
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 | Edit
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 | Del
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 | Add
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 | Player
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 | Perks
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 | Steel armor
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 | Conjuration
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 | Level
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 | Down
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 | Up
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 | Name
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 | 2
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 | Strengh
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 | 6
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 | 1
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 | 2
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 | 3
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 | Amulet of destruction
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 | Expand
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 | Players count
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
--------------------------------------------------------------------------------
/app/050_starting/plan.odg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/050_starting/plan.odg
--------------------------------------------------------------------------------
/app/050_starting/plan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/050_starting/plan.png
--------------------------------------------------------------------------------
/app/060_resources/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/060_resources/screenshot.png
--------------------------------------------------------------------------------
/app/070_routing/router-v01.odg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/070_routing/router-v01.odg
--------------------------------------------------------------------------------
/app/070_routing/screenshot-edit-no-nav.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/070_routing/screenshot-edit-no-nav.png
--------------------------------------------------------------------------------
/app/070_routing/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/070_routing/screenshot.png
--------------------------------------------------------------------------------
/app/075/screenshot-edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/075/screenshot-edit.png
--------------------------------------------------------------------------------
/app/080_fetching_resources/flow-v01.pu:
--------------------------------------------------------------------------------
1 | @startuml
2 | participant StartApp as SA
3 | participant "port runner" as PR
4 | participant Main.Update as MU
5 | participant Main.View as MV
6 | participant Players.Update as PU
7 | participant Players.List as PL
8 |
9 | SA -> PR : 1. fetchAll
10 | PR -> SA : 2. response
11 | SA -> MU : 3. PlayersActions (FetchAllDone result)
12 | MU -> PU : 4. FetchAllDone result
13 | PU --> MU : 5. updated collection
14 | MU --> SA : 6. updated main model
15 | SA -> MV : 7. main model
16 | MV -> PL : 8. players
17 | PL --> MV : 9. rendered view
18 | MV --> SA : 10. rendered view
19 | @enduml
20 |
--------------------------------------------------------------------------------
/app/080_fetching_resources/flow-v02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/080_fetching_resources/flow-v02.png
--------------------------------------------------------------------------------
/app/080_fetching_resources/flow-v03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/080_fetching_resources/flow-v03.png
--------------------------------------------------------------------------------
/app/090_showing_errors/flow-v01.pu:
--------------------------------------------------------------------------------
1 | @startuml
2 | participant actionsMailbox as AM
3 | participant StartApp as SA
4 | participant Main.Update as MU
5 | participant Main.View as MV
6 | participant Players.Update as PU
7 |
8 | MU -> PU: 1. FetchDone
9 | PU --> AM: 2. error
10 | AM -> SA: 3. ShowError msg
11 | SA -> MU: 4. ShowError msg
12 | MU --> SA: 5. model
13 | SA -> MV: 6. model
14 | MV --> SA: 7. rendered view
15 | @enduml
16 |
--------------------------------------------------------------------------------
/app/090_showing_errors/flow-v05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/090_showing_errors/flow-v05.png
--------------------------------------------------------------------------------
/app/090_showing_errors/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/090_showing_errors/screenshot.png
--------------------------------------------------------------------------------
/app/100_adding_players/flow-v01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/100_adding_players/flow-v01.png
--------------------------------------------------------------------------------
/app/100_adding_players/flow-v02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/100_adding_players/flow-v02.png
--------------------------------------------------------------------------------
/app/100_adding_players/flow-v03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/100_adding_players/flow-v03.png
--------------------------------------------------------------------------------
/app/100_adding_players/flow-v04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/100_adding_players/flow-v04.png
--------------------------------------------------------------------------------
/app/100_adding_players/flow.pu:
--------------------------------------------------------------------------------
1 | @startuml
2 | participant "port runner" as PR
3 | participant StartApp as SA
4 | participant Main.Update as MU
5 | participant Main.View as MV
6 | participant Players.Update as PU
7 | participant Players.List as PL
8 |
9 | PL -> SA : 1. CreatePlayer
10 | SA -> MU : 2. PlayersActions CreatePlayer
11 | MU -> PU : 3. CreatePlayer
12 | PU --> MU : 4. create effect
13 | MU --> SA : 5. create effect
14 | SA -> PR : 6. create effect
15 | PR -> SA : 7. response
16 | SA -> MU : 8. PlayersAction (CreatePlayerDone result)
17 | MU -> PU : 9. CreatePlayerDone result
18 | PU --> MU : 10. updated collection
19 | MU --> SA : 11. updated main model
20 | SA -> MV : 12. app model
21 | MV -> PL : 13. players
22 | PL --> MV : 14. rendered list
23 | MV --> SA : 15. renderer view
24 | @enduml
25 |
--------------------------------------------------------------------------------
/app/100_adding_players/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/100_adding_players/screenshot.png
--------------------------------------------------------------------------------
/app/110_deleting/flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/110_deleting/flow.png
--------------------------------------------------------------------------------
/app/110_deleting/flow.pu:
--------------------------------------------------------------------------------
1 | @startuml
2 | participant JS
3 | participant "port runner" as PR
4 | participant askDeleteConfirmationMailbox as DCM
5 | participant getDeleteConfirmation
6 | participant StartApp as SA
7 | participant Main.Update as MU
8 | participant Main.View as MV
9 | participant Players.Update as PU
10 | participant Players.List as PL
11 |
12 | PL -> SA : 1. DeletePlayerIntent player
13 | SA -> MU : 2. PlayersActions (DeletePlayerIntent player)
14 | MU -> PU : 3. DeletePlayerIntent player
15 | PU --> DCM : 4. (playerId, msg)
16 | DCM -> JS : 5. (playerId, msg)
17 | JS -> getDeleteConfirmation : 6. playerId
18 | getDeleteConfirmation -> SA : 7. playerId
19 | SA -> MU : 8. PlayersActions (DeletePlayer playerId)
20 | MU -> PU : 9. DeletePlayer playerId
21 | PU --> MU : 10. delete effect
22 | MU --> SA : 11. delete effect
23 | SA --> PR : 12. delete effect
24 | PR -> SA : 13. response
25 | SA -> MU : 14. PlayersActions (DeletePlayerDone playerId)
26 | MU -> PU : 15. DeletePlayerDone playerId
27 | PU --> MU : 16. updated collection
28 | MU --> SA : 17. updated main model
29 | SA -> MV : 18. main model
30 | MV -> PL : 19. players
31 | PL --> MV : 20. rendered list
32 | MV --> SA : 21. renderer view
33 | @enduml
34 |
--------------------------------------------------------------------------------
/app/110_deleting/screencast.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/110_deleting/screencast.gif
--------------------------------------------------------------------------------
/app/110_deleting/screencast.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/110_deleting/screencast.mp4
--------------------------------------------------------------------------------
/app/110_deleting/screenshot-confirm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/110_deleting/screenshot-confirm.png
--------------------------------------------------------------------------------
/app/110_deleting/screenshot-list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/110_deleting/screenshot-list.png
--------------------------------------------------------------------------------
/app/120_edit/screenshot-level.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/120_edit/screenshot-level.png
--------------------------------------------------------------------------------
/app/elm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/elm.png
--------------------------------------------------------------------------------
/app/logo-v01.idraw:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/logo-v01.idraw
--------------------------------------------------------------------------------
/app/logo-v01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/logo-v01.png
--------------------------------------------------------------------------------
/app/logo-v02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/app/logo-v02.png
--------------------------------------------------------------------------------
/code/010_foundations/Hello.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html
4 |
5 |
6 | main : Html.Html
7 | main =
8 | Html.text "Hello"
9 |
--------------------------------------------------------------------------------
/code/010_foundations/TypeVariables.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html
4 | import Array
5 |
6 |
7 | indexOf : a -> Array.Array a -> Int
8 | indexOf target array =
9 | -1
10 |
11 |
12 | switch : ( a, b ) -> ( b, a )
13 | switch ( x, y ) =
14 | ( y, x )
15 |
16 |
17 | main =
18 | Html.text (toString (indexOf 1 (Array.fromList [ 1, 2 ])))
19 |
20 |
21 |
22 | --Html.text (toString (switch ("d", 2)))
23 |
--------------------------------------------------------------------------------
/code/020_signals/BasicMouse.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html exposing (Html)
4 | import Mouse
5 |
6 |
7 | view : Int -> Html
8 | view x =
9 | Html.text (toString x)
10 |
11 |
12 | main : Signal.Signal Html
13 | main =
14 | Signal.map view Mouse.x
15 |
--------------------------------------------------------------------------------
/code/020_signals/BasicMouseDouble.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html
4 | import Mouse
5 |
6 |
7 | double : Int -> Int
8 | double x =
9 | x * 2
10 |
11 |
12 | doubleSignal : Signal Int
13 | doubleSignal =
14 | Signal.map double Mouse.x
15 |
16 |
17 | view : Int -> Html.Html
18 | view x =
19 | Html.text (toString x)
20 |
21 |
22 | main : Signal.Signal Html.Html
23 | main =
24 | Signal.map view doubleSignal
25 |
--------------------------------------------------------------------------------
/code/020_signals/Clicks.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html exposing (Html)
4 | import Mouse
5 |
6 |
7 | view : Int -> Html
8 | view count =
9 | Html.text (toString count)
10 |
11 |
12 | countSignal : Signal Int
13 | countSignal =
14 | Signal.map (always 1) Mouse.clicks
15 |
16 |
17 | main : Signal.Signal Html
18 | main =
19 | Signal.map view countSignal
20 |
--------------------------------------------------------------------------------
/code/020_signals/ClicksWithFoldp.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html exposing (Html)
4 | import Mouse
5 |
6 |
7 | view : Int -> Html
8 | view count =
9 | Html.text (toString count)
10 |
11 |
12 | countSignal : Signal Int
13 | countSignal =
14 | Signal.foldp (\_ state -> state + 1) 0 Mouse.clicks
15 |
16 |
17 | main : Signal.Signal Html
18 | main =
19 | Signal.map view countSignal
20 |
--------------------------------------------------------------------------------
/code/020_signals/Mailbox01.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html exposing (Html)
4 |
5 |
6 | view : String -> Html
7 | view message =
8 | Html.div
9 | []
10 | [ Html.div [] [ Html.text message ]
11 | , Html.button [] [ Html.text "Click" ]
12 | ]
13 |
14 |
15 | messageSignal : Signal String
16 | messageSignal =
17 | Signal.constant "Hello"
18 |
19 |
20 | main : Signal Html
21 | main =
22 | Signal.map view messageSignal
23 |
--------------------------------------------------------------------------------
/code/020_signals/Mailbox02.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html exposing (Html)
4 | import Html.Events as Events
5 |
6 |
7 | view : Signal.Address String -> String -> Html
8 | view address message =
9 | Html.div
10 | []
11 | [ Html.div [] [ Html.text message ]
12 | , Html.button
13 | [ Events.onClick address "Hello"
14 | ]
15 | [ Html.text "Click" ]
16 | ]
17 |
18 |
19 | mb : Signal.Mailbox String
20 | mb =
21 | Signal.mailbox ""
22 |
23 |
24 | main : Signal Html
25 | main =
26 | Signal.map (view mb.address) mb.signal
27 |
--------------------------------------------------------------------------------
/code/040_effects/Effects.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html
4 | import Html.Events as Events
5 | import Http
6 | import Task
7 | import Debug
8 | import Effects
9 |
10 |
11 | type Action
12 | = NoOp
13 | | Refresh
14 | | OnRefresh (Result Http.Error String)
15 |
16 |
17 | type alias Model =
18 | String
19 |
20 |
21 | view : Signal.Address Action -> Model -> Html.Html
22 | view address message =
23 | Html.div
24 | []
25 | [ Html.button
26 | [ Events.onClick address Refresh
27 | ]
28 | [ Html.text "Refresh"
29 | ]
30 | , Html.text message
31 | ]
32 |
33 |
34 | actionsMailbox : Signal.Mailbox (List Action)
35 | actionsMailbox =
36 | Signal.mailbox []
37 |
38 |
39 | oneActionAddress : Signal.Address Action
40 | oneActionAddress =
41 | Signal.forwardTo actionsMailbox.address (\action -> [ action ])
42 |
43 |
44 | httpTask : Task.Task Http.Error String
45 | httpTask =
46 | Http.getString "http://localhost:3000/"
47 |
48 |
49 | refreshFx : Effects.Effects Action
50 | refreshFx =
51 | httpTask
52 | |> Task.toResult
53 | |> Task.map OnRefresh
54 | |> Effects.task
55 |
56 |
57 | update : Action -> Model -> ( Model, Effects.Effects Action )
58 | update action model =
59 | case Debug.log "action" action of
60 | Refresh ->
61 | ( model, refreshFx )
62 |
63 | OnRefresh result ->
64 | let
65 | message =
66 | Result.withDefault "" result
67 | in
68 | ( message, Effects.none )
69 |
70 | _ ->
71 | ( model, Effects.none )
72 |
73 |
74 | modelAndFxSignal : Signal.Signal ( Model, Effects.Effects Action )
75 | modelAndFxSignal =
76 | let
77 | modelAndFx action ( previousModel, _ ) =
78 | update action previousModel
79 |
80 | modelAndManyFxs actions ( previousModel, _ ) =
81 | List.foldl modelAndFx ( previousModel, Effects.none ) actions
82 |
83 | initial =
84 | ( "-", Effects.none )
85 | in
86 | Signal.foldp modelAndManyFxs initial actionsMailbox.signal
87 |
88 |
89 | modelSignal : Signal.Signal Model
90 | modelSignal =
91 | Signal.map fst modelAndFxSignal
92 |
93 |
94 | fxSignal : Signal.Signal (Effects.Effects Action)
95 | fxSignal =
96 | Signal.map snd modelAndFxSignal
97 |
98 |
99 | taskSignal : Signal (Task.Task Effects.Never ())
100 | taskSignal =
101 | Signal.map (Effects.toTask actionsMailbox.address) fxSignal
102 |
103 |
104 | main : Signal.Signal Html.Html
105 | main =
106 | Signal.map (view oneActionAddress) modelSignal
107 |
108 |
109 | port runner : Signal (Task.Task Effects.Never ())
110 | port runner =
111 | taskSignal
112 |
--------------------------------------------------------------------------------
/code/040_effects/StartApp.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Effects exposing (Effects, Never)
4 | import Html
5 | import Html.Events as Events
6 | import Http
7 | import StartApp
8 | import Task
9 |
10 |
11 | type Action
12 | = NoOp
13 | | Refresh
14 | | OnRefresh (Result Http.Error String)
15 |
16 |
17 | type alias Model =
18 | String
19 |
20 |
21 | view : Signal.Address Action -> Model -> Html.Html
22 | view address message =
23 | Html.div
24 | []
25 | [ Html.button
26 | [ Events.onClick address Refresh
27 | ]
28 | [ Html.text "Refresh"
29 | ]
30 | , Html.text message
31 | ]
32 |
33 |
34 | httpTask : Task.Task Http.Error String
35 | httpTask =
36 | Http.getString "http://localhost:3000/"
37 |
38 |
39 | refreshFx : Effects.Effects Action
40 | refreshFx =
41 | httpTask
42 | |> Task.toResult
43 | |> Task.map OnRefresh
44 | |> Effects.task
45 |
46 |
47 | init : ( Model, Effects Action )
48 | init =
49 | ( "", Effects.none )
50 |
51 |
52 | update : Action -> Model -> ( Model, Effects.Effects Action )
53 | update action model =
54 | case Debug.log "action" action of
55 | Refresh ->
56 | ( model, refreshFx )
57 |
58 | OnRefresh result ->
59 | let
60 | message =
61 | Result.withDefault "" result
62 | in
63 | ( message, Effects.none )
64 |
65 | _ ->
66 | ( model, Effects.none )
67 |
68 |
69 | app : StartApp.App Model
70 | app =
71 | StartApp.start
72 | { init = init
73 | , inputs = []
74 | , update = update
75 | , view = view
76 | }
77 |
78 |
79 | main : Signal.Signal Html.Html
80 | main =
81 | app.html
82 |
83 |
84 | port runner : Signal (Task.Task Never ())
85 | port runner =
86 | app.tasks
87 |
--------------------------------------------------------------------------------
/code/040_effects/Tasks01.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html
4 | import Time
5 |
6 |
7 | clockSignal : Signal Time.Time
8 | clockSignal =
9 | Time.every Time.second
10 |
11 |
12 | messageSignal : Signal String
13 | messageSignal =
14 | Signal.map toString clockSignal
15 |
16 |
17 | view : String -> Html.Html
18 | view message =
19 | Html.text message
20 |
21 |
22 | main : Signal.Signal Html.Html
23 | main =
24 | Signal.map view messageSignal
25 |
--------------------------------------------------------------------------------
/code/040_effects/Tasks02.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html
4 | import Time
5 | import Http
6 | import Task
7 |
8 |
9 | view : String -> Html.Html
10 | view message =
11 | Html.text message
12 |
13 |
14 | clockSignal : Signal Time.Time
15 | clockSignal =
16 | Time.every (2 * Time.second)
17 |
18 |
19 | mb : Signal.Mailbox String
20 | mb =
21 | Signal.mailbox ""
22 |
23 |
24 | httpTask : Task.Task Http.Error String
25 | httpTask =
26 | Http.getString "http://localhost:3000/"
27 |
28 |
29 | sendToMb : String -> Task.Task x ()
30 | sendToMb result =
31 | Signal.send mb.address result
32 |
33 |
34 | runTask : Task.Task Http.Error ()
35 | runTask =
36 | Task.andThen httpTask sendToMb
37 |
38 |
39 | taskSignal : Signal (Task.Task Http.Error ())
40 | taskSignal =
41 | Signal.map (always runTask) clockSignal
42 |
43 |
44 | main : Signal.Signal Html.Html
45 | main =
46 | Signal.map view mb.signal
47 |
48 |
49 | port runner : Signal (Task.Task Http.Error ())
50 | port runner =
51 | taskSignal
52 |
--------------------------------------------------------------------------------
/code/C030ElmArch/Actions.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html exposing (Html)
4 | import Mouse
5 |
6 |
7 | type alias Model =
8 | { count : Int
9 | }
10 |
11 |
12 | type Action
13 | = NoOp
14 | | Increase
15 |
16 |
17 | initialModel : Model
18 | initialModel =
19 | { count = 0
20 | }
21 |
22 |
23 | view : Model -> Html
24 | view model =
25 | Html.text (toString model.count)
26 |
27 |
28 | update : Action -> Model -> Model
29 | update action model =
30 | case action of
31 | Increase ->
32 | { model | count = model.count + 1 }
33 |
34 | NoOp ->
35 | model
36 |
37 |
38 | actionSignal : Signal.Signal Action
39 | actionSignal =
40 | Signal.map (\_ -> Increase) Mouse.clicks
41 |
42 |
43 | modelSignal : Signal.Signal Model
44 | modelSignal =
45 | Signal.foldp update initialModel actionSignal
46 |
47 |
48 | main : Signal.Signal Html
49 | main =
50 | Signal.map view modelSignal
51 |
--------------------------------------------------------------------------------
/code/C030ElmArch/ActionsMultiple.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html exposing (Html)
4 | import Mouse
5 | import Keyboard
6 |
7 |
8 | type alias Model =
9 | { count : Int
10 | }
11 |
12 |
13 | type Action
14 | = NoOp
15 | | MouseClick
16 | | KeyPress
17 |
18 |
19 | initialModel : Model
20 | initialModel =
21 | { count = 0
22 | }
23 |
24 |
25 | view : Model -> Html
26 | view model =
27 | Html.text (toString model.count)
28 |
29 |
30 | update : Action -> Model -> Model
31 | update action model =
32 | case action of
33 | MouseClick ->
34 | { model | count = model.count + 1 }
35 |
36 | KeyPress ->
37 | { model | count = model.count - 1 }
38 |
39 | _ ->
40 | model
41 |
42 |
43 | mouseClickSignal : Signal.Signal Action
44 | mouseClickSignal =
45 | Signal.map (\_ -> MouseClick) Mouse.clicks
46 |
47 |
48 | keyPressSignal : Signal.Signal Action
49 | keyPressSignal =
50 | Signal.map (\_ -> KeyPress) Keyboard.presses
51 |
52 |
53 | actionSignal : Signal.Signal Action
54 | actionSignal =
55 | Signal.merge mouseClickSignal keyPressSignal
56 |
57 |
58 | modelSignal : Signal.Signal Model
59 | modelSignal =
60 | Signal.foldp update initialModel actionSignal
61 |
62 |
63 | main : Signal.Signal Html
64 | main =
65 | Signal.map view modelSignal
66 |
--------------------------------------------------------------------------------
/code/C030ElmArch/ActionsWithPayload.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html exposing (Html)
4 | import Mouse
5 |
6 |
7 | type alias Model =
8 | { count : Int
9 | }
10 |
11 |
12 | type Action
13 | = NoOp
14 | | MouseClick Int
15 |
16 |
17 | initialModel : Model
18 | initialModel =
19 | { count = 0
20 | }
21 |
22 |
23 | view : Model -> Html
24 | view model =
25 | Html.text (toString model.count)
26 |
27 |
28 | update : Action -> Model -> Model
29 | update action model =
30 | case action of
31 | MouseClick amount ->
32 | { model | count = model.count + amount }
33 |
34 | _ ->
35 | model
36 |
37 |
38 | mouseClickSignal : Signal.Signal Action
39 | mouseClickSignal =
40 | Signal.map (\_ -> MouseClick 2) Mouse.clicks
41 |
42 |
43 | modelSignal : Signal.Signal Model
44 | modelSignal =
45 | Signal.foldp update initialModel mouseClickSignal
46 |
47 |
48 | main : Signal.Signal Html
49 | main =
50 | Signal.map view modelSignal
51 |
--------------------------------------------------------------------------------
/code/C030ElmArch/Composing/App.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html exposing (Html)
4 | import StartApp.Simple
5 | import C030ElmArch.Composing.Widget as Widget
6 |
7 |
8 | -- MODEL
9 |
10 |
11 | type alias AppModel =
12 | { widgetModel : Widget.Model
13 | }
14 |
15 |
16 | initialModel : AppModel
17 | initialModel =
18 | { widgetModel = Widget.initialModel
19 | }
20 |
21 |
22 | type Action
23 | = WidgetAction Widget.Action
24 |
25 |
26 |
27 | -- VIEW
28 |
29 |
30 | view : Signal.Address Action -> AppModel -> Html
31 | view address model =
32 | Html.div
33 | []
34 | [ Widget.view (Signal.forwardTo address WidgetAction) model.widgetModel
35 | ]
36 |
37 |
38 |
39 | -- UPDATE
40 |
41 |
42 | update : Action -> AppModel -> AppModel
43 | update action model =
44 | case action of
45 | WidgetAction subAction ->
46 | let
47 | updatedWidgetModel =
48 | Widget.update subAction model.widgetModel
49 | in
50 | { model | widgetModel = updatedWidgetModel }
51 |
52 |
53 |
54 | -- START APP
55 |
56 |
57 | main : Signal.Signal Html
58 | main =
59 | StartApp.Simple.start
60 | { model = initialModel
61 | , view = view
62 | , update = update
63 | }
64 |
--------------------------------------------------------------------------------
/code/C030ElmArch/Composing/Widget.elm:
--------------------------------------------------------------------------------
1 | module C030ElmArch.Composing.Widget (..) where
2 |
3 | import Html exposing (Html)
4 | import Html.Events as Events
5 |
6 |
7 | -- MODEL
8 |
9 |
10 | type alias Model =
11 | { count : Int
12 | }
13 |
14 |
15 | initialModel : Model
16 | initialModel =
17 | { count = 0
18 | }
19 |
20 |
21 | type Action
22 | = Increase
23 |
24 |
25 |
26 | -- VIEW
27 |
28 |
29 | view : Signal.Address Action -> Model -> Html
30 | view address model =
31 | Html.div
32 | []
33 | [ Html.div [] [ Html.text (toString model.count) ]
34 | , Html.button
35 | [ Events.onClick address Increase
36 | ]
37 | [ Html.text "Click" ]
38 | ]
39 |
40 |
41 |
42 | -- UPDATE
43 |
44 |
45 | update : Action -> Model -> Model
46 | update action model =
47 | case action of
48 | Increase ->
49 | { model | count = model.count + 1 }
50 |
--------------------------------------------------------------------------------
/code/C030ElmArch/Composing/flow-v01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sporto/elm-tutorial-assets/7ed6f57f73f71b57f6816ba39c9a1f6d60cc9879/code/C030ElmArch/Composing/flow-v01.png
--------------------------------------------------------------------------------
/code/C030ElmArch/Composing/flow.pu:
--------------------------------------------------------------------------------
1 | @startuml
2 | participant StartApp as SA
3 | participant Main.initialModel as Mim
4 | participant Main.view as MV
5 | participant Main.update as MU
6 | participant Widget.initialModel as Wim
7 | participant Widget.view as WV
8 | participant Widget.update as WU
9 |
10 | SA -> Mim: 1. initialModel
11 | Mim -> Wim: 2. initialModel
12 | Wim --> Mim: 3. widgetModel
13 | Mim --> SA: 4. mainModel
14 | SA -> MV : 5. mainAddress mainModel
15 | MV -> WV : 6. widgetAddress widgetModel
16 | WV --> MV : 7. Html
17 | MV --> SA : 8. Html
18 |
19 | WV -> SA: 9. Increase
20 | SA -> MU: 10. (WidgetAction Increase) mainModel
21 | MU -> WU : 11. Increase widgetModel
22 | WU --> MU: 12. updated widgetModel
23 | MU -> SA: 13. updated mainModel
24 | SA -> MV : 14. mainAddress mainModel
25 | MV -> WV : 15. widgetAddress widgetModel
26 | WV --> MV : 16. Html
27 | MV --> SA : 17. Html
28 | @enduml
29 |
--------------------------------------------------------------------------------
/code/C030ElmArch/Mailbox.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html exposing (Html)
4 | import Html.Events as Events
5 |
6 |
7 | type alias Model =
8 | { count : Int
9 | }
10 |
11 |
12 | type Action
13 | = NoOp
14 | | Increase
15 |
16 |
17 | initialModel : Model
18 | initialModel =
19 | { count = 0
20 | }
21 |
22 |
23 | view : Signal.Address Action -> Model -> Html
24 | view address model =
25 | Html.div
26 | []
27 | [ Html.div [] [ Html.text (toString model.count) ]
28 | , Html.button
29 | [ Events.onClick address Increase
30 | ]
31 | [ Html.text "Click" ]
32 | ]
33 |
34 |
35 | update : Action -> Model -> Model
36 | update action model =
37 | { model | count = model.count + 1 }
38 |
39 |
40 | mb : Signal.Mailbox Action
41 | mb =
42 | Signal.mailbox NoOp
43 |
44 |
45 | modelSignal : Signal.Signal Model
46 | modelSignal =
47 | Signal.foldp update initialModel mb.signal
48 |
49 |
50 | main : Signal.Signal Html
51 | main =
52 | Signal.map (view mb.address) modelSignal
53 |
--------------------------------------------------------------------------------
/code/C030ElmArch/Model.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html exposing (Html)
4 | import Mouse
5 |
6 |
7 | type alias Model =
8 | { count : Int
9 | }
10 |
11 |
12 | initialModel : Model
13 | initialModel =
14 | { count = 0
15 | }
16 |
17 |
18 | view : Model -> Html
19 | view model =
20 | Html.text (toString model.count)
21 |
22 |
23 | modelSignal : Signal.Signal Model
24 | modelSignal =
25 | Signal.foldp (\_ state -> { state | count = state.count + 1 }) initialModel Mouse.clicks
26 |
27 |
28 | main : Signal.Signal Html
29 | main =
30 | Signal.map view modelSignal
31 |
--------------------------------------------------------------------------------
/code/C030ElmArch/StartAppSimple.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html exposing (Html)
4 | import Html.Events as Events
5 | import StartApp.Simple
6 |
7 |
8 | type alias Model =
9 | { count : Int
10 | }
11 |
12 |
13 | type Action
14 | = NoOp
15 | | Increase
16 |
17 |
18 | initialModel : Model
19 | initialModel =
20 | { count = 0
21 | }
22 |
23 |
24 | view : Signal.Address Action -> Model -> Html
25 | view address model =
26 | Html.div
27 | []
28 | [ Html.div [] [ Html.text (toString model.count) ]
29 | , Html.button
30 | [ Events.onClick address Increase
31 | ]
32 | [ Html.text "Click" ]
33 | ]
34 |
35 |
36 | update : Action -> Model -> Model
37 | update action model =
38 | case action of
39 | Increase ->
40 | { model | count = model.count + 1 }
41 |
42 | _ ->
43 | model
44 |
45 |
46 | main : Signal.Signal Html
47 | main =
48 | StartApp.Simple.start
49 | { model = initialModel
50 | , view = view
51 | , update = update
52 | }
53 |
--------------------------------------------------------------------------------
/code/C030ElmArch/Update.elm:
--------------------------------------------------------------------------------
1 | module Main (..) where
2 |
3 | import Html exposing (Html)
4 | import Mouse
5 |
6 |
7 | type alias Model =
8 | { count : Int
9 | }
10 |
11 |
12 | initialModel : Model
13 | initialModel =
14 | { count = 0
15 | }
16 |
17 |
18 | view : Model -> Html
19 | view model =
20 | Html.text (toString model.count)
21 |
22 |
23 | update : () -> Model -> Model
24 | update _ model =
25 | { model | count = model.count + 1 }
26 |
27 |
28 | modelSignal : Signal.Signal Model
29 | modelSignal =
30 | Signal.foldp update initialModel Mouse.clicks
31 |
32 |
33 | main : Signal.Signal Html
34 | main =
35 | Signal.map view modelSignal
36 |
--------------------------------------------------------------------------------
/code/elm-package.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0",
3 | "summary": "helpful summary of your project, less than 80 characters",
4 | "repository": "https://github.com/user/project.git",
5 | "license": "BSD3",
6 | "source-directories": [
7 | "."
8 | ],
9 | "exposed-modules": [],
10 | "dependencies": {
11 | "elm-lang/core": "3.0.0 <= v < 4.0.0",
12 | "evancz/elm-effects": "2.0.1 <= v < 3.0.0",
13 | "evancz/elm-html": "4.0.2 <= v < 5.0.0",
14 | "evancz/elm-http": "3.0.0 <= v < 4.0.0",
15 | "evancz/start-app": "2.0.2 <= v < 3.0.0"
16 | },
17 | "elm-version": "0.16.0 <= v < 0.17.0"
18 | }
--------------------------------------------------------------------------------
/code/index.js:
--------------------------------------------------------------------------------
1 | var jsonServer = require('json-server')
2 |
3 | // Returns an Express server
4 | var server = jsonServer.create()
5 |
6 | server.use(function(req, res, next) {
7 | res.header("Access-Control-Allow-Origin", "*");
8 | res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
9 | next();
10 | });
11 |
12 | server.get('/', function (req, res) {
13 | res.send(Math.random().toString())
14 | })
15 |
16 | console.log('Listening at 3000')
17 | server.listen(3000)
18 |
--------------------------------------------------------------------------------
/code/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "code",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "elm.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "json-server": "^0.8.6"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | ### Deprecated Repository
2 |
3 | Assets and example code for http://www.elm-tutorial.org/
4 |
5 | ## Rendering UML diagrams
6 |
7 | - Download PlantUML http://plantuml.com/
8 | - Move somewhere in your path `mv plantuml.jar /usr/local/bin/`
9 | - Run:
10 |
11 | ```
12 | java -jar /usr/loca/bin/plantuml.jar diagram-file.uml
13 | ```
14 |
--------------------------------------------------------------------------------