Installed

elm/browser
1.0.2
elm/core
1.0.5
elm/html
1.0.0
elm/http
2.0.0

Registry

elm/random
1.0.0
elm/time
1.0.0
elm/file
1.0.5
elm/json
1.1.3
elm/svg
1.0.1
evancz/elm-playground
1.0.3
elm-explorations/webgl
1.1.3
w0rm/elm-physics
5.1.3
rtfeldman/elm-css
18.0.0
mdgriffith/elm-ui
1.1.8
​x
 
1
-- Make a GET request to load a book called "Public Opinion"
2
--
3
-- Read how it works:
4
--   https://guide.elm-lang.org/effects/http.html
5
--
6
​
7
import Browser
8
import Html exposing (Html, text, pre)
9
import Http
10
​
11
​
12
​
13
-- MAIN
14
​
15
​
16
main =
17
  Browser.element
18
    { init = init
19
    , update = update
20
    , subscriptions = subscriptions
21
    , view = view
22
    }
23
​
24
​
25
​
26
-- MODEL
27
​
28
​
29
type Model
30
  = Failure
31
  | Loading
32
  | Success String
33
​
34
​
35
init : () -> (Model, Cmd Msg)
36
init _ =
37
  ( Loading
38
  , Http.get
39
      { url = "https://elm-lang.org/assets/public-opinion.txt"
40
      , expect = Http.expectString GotText
41
      }
42
  )
43
​
44
​
45
​
46
-- UPDATE
47
​
48
​
49
type Msg