forked from elm/compiler
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4dd19a1
commit 5194a0a
Showing
30 changed files
with
2,554 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Animation exposing (main) | ||
|
||
-- Create animations that spin, wave, and zig-zag. | ||
-- This one is a little red wagon bumping along a dirt road. | ||
-- | ||
-- Learn more about the playground here: | ||
-- https://package.elm-lang.org/packages/evancz/elm-playground/latest/ | ||
-- | ||
|
||
import Playground exposing (..) | ||
|
||
|
||
main = | ||
animation view | ||
|
||
|
||
view time = | ||
[ octagon darkGray 36 | ||
|> moveLeft 100 | ||
|> rotate (spin 3 time) | ||
, octagon darkGray 36 | ||
|> moveRight 100 | ||
|> rotate (spin 3 time) | ||
, rectangle red 300 80 | ||
|> moveUp (wave 50 54 2 time) | ||
|> rotate (zigzag -2 2 8 time) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
module Book exposing (main) | ||
|
||
-- Make a GET request to load a book called "Public Opinion" | ||
-- | ||
-- Read how it works: | ||
-- https://guide.elm-lang.org/effects/http.html | ||
-- | ||
|
||
import Browser | ||
import Html exposing (Html, pre, text) | ||
import Http | ||
|
||
|
||
|
||
-- MAIN | ||
|
||
|
||
main = | ||
Browser.element | ||
{ init = init | ||
, update = update | ||
, subscriptions = subscriptions | ||
, view = view | ||
} | ||
|
||
|
||
|
||
-- MODEL | ||
|
||
|
||
type Model | ||
= Failure | ||
| Loading | ||
| Success String | ||
|
||
|
||
init : () -> ( Model, Cmd Msg ) | ||
init _ = | ||
( Loading | ||
, Http.get | ||
{ url = "https://elm-lang.org/assets/public-opinion.txt" | ||
, expect = Http.expectString GotText | ||
} | ||
) | ||
|
||
|
||
|
||
-- UPDATE | ||
|
||
|
||
type Msg | ||
= GotText (Result Http.Error String) | ||
|
||
|
||
update : Msg -> Model -> ( Model, Cmd Msg ) | ||
update msg model = | ||
case msg of | ||
GotText result -> | ||
case result of | ||
Ok fullText -> | ||
( Success fullText, Cmd.none ) | ||
|
||
Err _ -> | ||
( Failure, Cmd.none ) | ||
|
||
|
||
|
||
-- SUBSCRIPTIONS | ||
|
||
|
||
subscriptions : Model -> Sub Msg | ||
subscriptions model = | ||
Sub.none | ||
|
||
|
||
|
||
-- VIEW | ||
|
||
|
||
view : Model -> Html Msg | ||
view model = | ||
case model of | ||
Failure -> | ||
text "I was unable to load your book." | ||
|
||
Loading -> | ||
text "Loading..." | ||
|
||
Success fullText -> | ||
pre [] [ text fullText ] |
Oops, something went wrong.