<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Elmseeds</title>
    <description>Short screencasts to teach you the Elm programming language. Each video tutorial walks through a library, tool, or language feature.
</description>
    <link>https://elmseeds.thaterikperson.com/</link>
    <atom:link href="https://elmseeds.thaterikperson.com/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Wed, 28 Feb 2018 19:39:14 +0000</pubDate>
    <lastBuildDate>Wed, 28 Feb 2018 19:39:14 +0000</lastBuildDate>
    <generator>Jekyll v3.6.2</generator>
    
      <item>
        <title>SPA - WebData Page Model</title>
        <description>
          
          
            &lt;video width=&quot;100%&quot; height=&quot;100%&quot; controls poster=&quot;https://s3.amazonaws.com/elmseeds/ep-055/cover-art-960.png&quot;&gt;
              &lt;source src=&quot;https://s3.amazonaws.com/elmseeds/ep-055/ep-055.mp4&quot; type=&quot;video/mp4&quot; /&gt;
            &lt;/video&gt;
          
          &lt;p&gt;As we add new pages to our application, and data to our model, the complexity and maintainability
of our application increases. Using the &lt;a href=&quot;http://package.elm-lang.org/packages/krisajenkins/remotedata/latest&quot;&gt;RemoteData&lt;/a&gt; pattern, we can modify our
page type to represent only the current, valid state of the app.&lt;/p&gt;

&lt;h3 id=&quot;examples&quot;&gt;Examples&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Main.elm&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-elm&quot;&gt;type Msg
    = TopStoriesFetched (WebData HomeModel)


type Page
    = Home (WebData HomeModel)


type alias HomeModel =
    { topStories : List StoryId }


type alias Model =
    { page : Page
    }


update : Msg -&amp;gt; Model -&amp;gt; ( Model, Cmd Msg )
update msg model =
    case msg of
        TopStoriesFetched webData -&amp;gt;
            ( { model | page = Home webData }, Cmd.none )
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;links&quot;&gt;Links&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://elmseeds.thaterikperson.com/remotedata&quot;&gt;Elmseeds Episode 37: RemoteData&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

        </description>
        <pubDate>Wed, 28 Feb 2018 07:38:00 +0000</pubDate>
        <link>https://elmseeds.thaterikperson.com/webdata-page-model</link>
        <guid isPermaLink="true">https://elmseeds.thaterikperson.com/webdata-page-model</guid>
        
        
      </item>
    
      <item>
        <title>SPA - HTTP Requests</title>
        <description>
          
          
            &lt;video width=&quot;100%&quot; height=&quot;100%&quot; controls poster=&quot;https://s3.amazonaws.com/elmseeds/ep-054/cover-art-960.png&quot;&gt;
              &lt;source src=&quot;https://s3.amazonaws.com/elmseeds/ep-054/ep-054.mp4&quot; type=&quot;video/mp4&quot; /&gt;
            &lt;/video&gt;
          
          &lt;p&gt;It’s time to add some data to our Single Page Application. Because we’re building a Hacker News clone, we’ll use the official Hacker News API to
fetch data. We can do this with some simple HTTP requests using &lt;a href=&quot;http://package.elm-lang.org/packages/elm-lang/http&quot;&gt;elm-lang/http&lt;/a&gt;. In this episode
we’ll setup our application to automatically load the Top Stories whenever the user launches the application on the home page, or navigates to it 
from within the app.&lt;/p&gt;

&lt;h3 id=&quot;examples&quot;&gt;Examples&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Main.elm&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-elm&quot;&gt;type StoryId
    = StoryId String


storyIdDecoder : Decoder StoryId
storyIdDecoder =
    Decode.map (StoryId &amp;lt;&amp;lt; toString) Decode.int


topStories : Http.Request (List StoryId)
topStories =
    Http.get &quot;https://hacker-news.firebaseio.com/v0/topstories.json&quot; (Decode.list storyIdDecoder)


setRoute : Location -&amp;gt; Model -&amp;gt; ( Model, Cmd Msg )
setRoute location model =
    let
        -- …
    in
        case route of
            Route.Home -&amp;gt;
                let
                    cmd =
                        Http.send TopStoriesFetched topStories
                in
                    ( { model | page = Home }, cmd )
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;links&quot;&gt;Links&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/HackerNews/API&quot;&gt;Official Hacker News API&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

        </description>
        <pubDate>Thu, 22 Feb 2018 18:42:00 +0000</pubDate>
        <link>https://elmseeds.thaterikperson.com/spa-http-requests</link>
        <guid isPermaLink="true">https://elmseeds.thaterikperson.com/spa-http-requests</guid>
        
        
      </item>
    
      <item>
        <title>SPA - Navigation</title>
        <description>
          
          
            &lt;video width=&quot;100%&quot; height=&quot;100%&quot; controls poster=&quot;https://s3.amazonaws.com/elmseeds/ep-053/cover-art-960.png&quot;&gt;
              &lt;source src=&quot;https://s3.amazonaws.com/elmseeds/ep-053/ep-053.mp4&quot; type=&quot;video/mp4&quot; /&gt;
            &lt;/video&gt;
          
          &lt;p&gt;The next step in our Single Page Application series is to add url routing and navigation. There are two packages we’ll need for this. The first, &lt;a href=&quot;http://package.elm-lang.org/packages/elm-lang/navigation/latest&quot;&gt;Navigation&lt;/a&gt;,
will allow us to handle navigation events and starting the application on a page other than the home page.&lt;/p&gt;

&lt;p&gt;The second package, &lt;a href=&quot;http://package.elm-lang.org/packages/evancz/url-parser/latest&quot;&gt;Url-Parser&lt;/a&gt;, helps us parse our url’s path into an Elm sum type
which we can use to determine which page to render in the view.&lt;/p&gt;

&lt;h3 id=&quot;examples&quot;&gt;Examples&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;shell&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Force the server to render index.html on 404s&lt;/span&gt;
./node_modules/.bin/webpack-dev-server &lt;span class=&quot;nt&quot;&gt;--history-api-fallback&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Main.elm&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-elm&quot;&gt;setRoute : Location -&amp;gt; Model -&amp;gt; Model
setRoute location model =
    let
        route =
            UrlParser.parsePath Route.route location
                |&amp;gt; Maybe.withDefault Route.Home
    in
        case route of
            Route.Home -&amp;gt;
                { model | page = Home }

            Route.Newest -&amp;gt;
                { model | page = Newest }

&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;links&quot;&gt;Links&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://package.elm-lang.org/packages/elm-lang/navigation/latest&quot;&gt;elm-lang/navigation&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://package.elm-lang.org/packages/evancz/url-parser/latest&quot;&gt;evancz/url-parser&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


        </description>
        <pubDate>Thu, 15 Feb 2018 18:43:00 +0000</pubDate>
        <link>https://elmseeds.thaterikperson.com/spa-navigation</link>
        <guid isPermaLink="true">https://elmseeds.thaterikperson.com/spa-navigation</guid>
        
        
      </item>
    
      <item>
        <title>SPA - Webpack Setup</title>
        <description>
          
          
            &lt;video width=&quot;100%&quot; height=&quot;100%&quot; controls poster=&quot;https://s3.amazonaws.com/elmseeds/ep-052/cover-art-960.png&quot;&gt;
              &lt;source src=&quot;https://s3.amazonaws.com/elmseeds/ep-052/ep-052.mp4&quot; type=&quot;video/mp4&quot; /&gt;
            &lt;/video&gt;
          
          &lt;p&gt;This episode begins a series in which we build a Single Page Application (SPA) clone of &lt;a href=&quot;https://news.ycombinator.com&quot;&gt;Hacker News&lt;/a&gt;. We’ll call our version Technologist News.&lt;/p&gt;

&lt;p&gt;We begin by setting up the most basic application and supporting infrastructure possible. We’ll use Webpack to do our automatic compilation.&lt;/p&gt;

&lt;h3 id=&quot;examples&quot;&gt;Examples&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;app.js&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Elm&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'../src/Main.elm'&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'main'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;main&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Elm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;embed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;index.html&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;main&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;main&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/main&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;script &lt;/span&gt;&lt;span class=&quot;na&quot;&gt;src=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/dist/bundle.js&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;links&quot;&gt;Links&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/HackerNews/API&quot;&gt;HackerNews API&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/rtfeldman/elm-spa-example&quot;&gt;rtfelman/elm-spa-example&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://elmseeds.thaterikperson.com/elm-webpack-loader&quot;&gt;Episode 39: Elm &amp;amp; Webpack&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


        </description>
        <pubDate>Thu, 08 Feb 2018 19:00:00 +0000</pubDate>
        <link>https://elmseeds.thaterikperson.com/spa-webpack-setup</link>
        <guid isPermaLink="true">https://elmseeds.thaterikperson.com/spa-webpack-setup</guid>
        
        
      </item>
    
      <item>
        <title>Advent of Code - Day 1</title>
        <description>
          
          
            &lt;video width=&quot;100%&quot; height=&quot;100%&quot; controls poster=&quot;https://s3.amazonaws.com/elmseeds/ep-051/cover-art-960.png&quot;&gt;
              &lt;source src=&quot;https://s3.amazonaws.com/elmseeds/ep-051/ep-051.mp4&quot; type=&quot;video/mp4&quot; /&gt;
            &lt;/video&gt;
          
          &lt;p&gt;&lt;a href=&quot;https://adventofcode.com/&quot;&gt;Advent of Code&lt;/a&gt; is a “series of small programming puzzles for a variety of skill levels.” It provides a perfect opportunity to challenge ourselves with Elm and build something out of the ordinary.&lt;/p&gt;

&lt;p&gt;The video &lt;strong&gt;does&lt;/strong&gt; contain spoilers, so if want to try to solve the problem on your own first, do that before watching this video. No code samples are provided here in order to hide spoilers.&lt;/p&gt;

        </description>
        <pubDate>Thu, 07 Dec 2017 19:00:00 +0000</pubDate>
        <link>https://elmseeds.thaterikperson.com/advent-of-code-day-one</link>
        <guid isPermaLink="true">https://elmseeds.thaterikperson.com/advent-of-code-day-one</guid>
        
        
      </item>
    
      <item>
        <title>Elm-Live</title>
        <description>
          
          
            &lt;video width=&quot;100%&quot; height=&quot;100%&quot; controls poster=&quot;https://s3.amazonaws.com/elmseeds/ep-050/cover-art-960.png&quot;&gt;
              &lt;source src=&quot;https://s3.amazonaws.com/elmseeds/ep-050/ep-050.mp4&quot; type=&quot;video/mp4&quot; /&gt;
            &lt;/video&gt;
          
          &lt;p&gt;&lt;a href=&quot;https://github.com/tomekwi/elm-live&quot;&gt;Elm-Live&lt;/a&gt; provides automatic compliation, a web server, and live reloading in a convenient package.&lt;/p&gt;

&lt;p&gt;If you already use Elm and want to recommend an easy path for others to get started, look no further than Elm-Live.&lt;/p&gt;

&lt;h3 id=&quot;examples&quot;&gt;Examples&lt;/h3&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;npm install &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt; elm-live
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;elm-live src/Main.elm &lt;span class=&quot;nt&quot;&gt;--output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;elm.js &lt;span class=&quot;nt&quot;&gt;--pushstate&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

        </description>
        <pubDate>Thu, 09 Nov 2017 19:08:00 +0000</pubDate>
        <link>https://elmseeds.thaterikperson.com/elm-live</link>
        <guid isPermaLink="true">https://elmseeds.thaterikperson.com/elm-live</guid>
        
        
      </item>
    
      <item>
        <title>Elm-Css</title>
        <description>
          
          
            &lt;video width=&quot;100%&quot; height=&quot;100%&quot; controls poster=&quot;https://s3.amazonaws.com/elmseeds/ep-049/cover-art-960.png&quot;&gt;
              &lt;source src=&quot;https://s3.amazonaws.com/elmseeds/ep-049/ep-049.mp4&quot; type=&quot;video/mp4&quot; /&gt;
            &lt;/video&gt;
          
          &lt;p&gt;&lt;a href=&quot;http://package.elm-lang.org/packages/rtfeldman/elm-css/latest&quot;&gt;Elm-Css&lt;/a&gt; can be used to write type-safe inline styles or generate Css files that you can include in your application normally.&lt;/p&gt;

&lt;h3 id=&quot;examples&quot;&gt;Examples&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Styles.elm&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-elm&quot;&gt;type Classes
    = GreenBg
    | White
    | Yellow


css : Css.Stylesheet
css =
    Css.stylesheet &amp;lt;|
        Css.Namespace.namespace &quot;main&quot;
            [ Css.class GreenBg
                [ Css.height (Css.px 300), Css.backgroundColor (Css.rgb 51 153 51) ]
            , Css.class White
                [ Css.color Colors.white ]
            , Css.class Yellow
                [ Css.color (Css.rgb 244 208 107) ]
            ]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;View.elm&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-elm&quot;&gt;{ id, class, classList } =
    Html.CssHelpers.withNamespace &quot;main&quot;


view : Model -&amp;gt; Html msg
view model =
    Html.header [ class [ GreenBg ] ]
        [ div []
            [ a [ href &quot;/&quot; ]
                [ span [] [ text &quot;Elm&quot; ]
                , span [] [ text &quot;seeds&quot; ]
                ]
            ]
        ]

&lt;/code&gt;&lt;/pre&gt;

&lt;h4 id=&quot;links&quot;&gt;Links&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://package.elm-lang.org/packages/rtfeldman/elm-css/latest&quot;&gt;rtfeldman/elm-css&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/30312715/run-command-after-webpack-build/35337516&quot;&gt;Stackoverflow: Run command after webpack build&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

        </description>
        <pubDate>Thu, 26 Oct 2017 18:00:00 +0000</pubDate>
        <link>https://elmseeds.thaterikperson.com/elm-css</link>
        <guid isPermaLink="true">https://elmseeds.thaterikperson.com/elm-css</guid>
        
        
      </item>
    
      <item>
        <title>Style Elements</title>
        <description>
          
          
            &lt;video width=&quot;100%&quot; height=&quot;100%&quot; controls poster=&quot;https://s3.amazonaws.com/elmseeds/ep-048/cover-art-960.png&quot;&gt;
              &lt;source src=&quot;https://s3.amazonaws.com/elmseeds/ep-048/ep-048.mp4&quot; type=&quot;video/mp4&quot; /&gt;
            &lt;/video&gt;
          
          &lt;p&gt;If you’ve written CSS for more than a week, you know how difficult it is to refactor without breaking something. &lt;a href=&quot;http://package.elm-lang.org/packages/mdgriffith/style-elements/latest&quot;&gt;Style Elements&lt;/a&gt; gives you the same safety and peace of mind in your view as you’re used to in the rest of your Elm application.&lt;/p&gt;

&lt;h3 id=&quot;examples&quot;&gt;Examples&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;View.elm&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-elm&quot;&gt;type Styles
    = GreenBg
    | None

view : Model -&amp;gt; Html msg
view model =
    El.layout styleSheet body


body : Element Styles v msg
body =
    El.column GreenBg
        [ height (px 300) ]
        [ header ]


header : Element Styles v msg
header =
    El.row None
        [ width fill, alignBottom ]
        [ El.link &quot;/&quot;
            (El.row None
                []
                [ El.el None [] (El.text &quot;Elm&quot;)
                , El.el None [] (El.text &quot;seeds&quot;)
                ]
            )
        ]


styleSheet : StyleSheet Styles v
styleSheet =
    Style.styleSheet
        [ Style.style GreenBg
            [ Style.Color.background (Color.rgb 51 153 51)
            ]
        ]
&lt;/code&gt;&lt;/pre&gt;

&lt;h4 id=&quot;links&quot;&gt;Links&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://package.elm-lang.org/packages/mdgriffith/style-elements/latest&quot;&gt;mdgriffith/style-elements&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://mdgriffith.gitbooks.io/style-elements/content/&quot;&gt;An Introduction to Style Elements for Elm&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

        </description>
        <pubDate>Thu, 12 Oct 2017 18:00:00 +0000</pubDate>
        <link>https://elmseeds.thaterikperson.com/style-elements</link>
        <guid isPermaLink="true">https://elmseeds.thaterikperson.com/style-elements</guid>
        
        
      </item>
    
      <item>
        <title>SelectList</title>
        <description>
          
          
            &lt;video width=&quot;100%&quot; height=&quot;100%&quot; controls poster=&quot;https://s3.amazonaws.com/elmseeds/ep-047/cover-art-960.png&quot;&gt;
              &lt;source src=&quot;https://s3.amazonaws.com/elmseeds/ep-047/ep-047.mp4&quot; type=&quot;video/mp4&quot; /&gt;
            &lt;/video&gt;
          
          &lt;p&gt;Modeling impossible state is an anti-pattern in Elm, so instead we need to come up with new approaches to model our application. If we want to model a list of items such that one is always selected, we can use the zipper data structure. It enforces that one item is always selected, and is the perfect complement to many UI patterns. In this episode, we use Richard Feldman’s &lt;a href=&quot;http://package.elm-lang.org/packages/rtfeldman/selectlist/latest&quot;&gt;selectlist&lt;/a&gt; to clean up problematic code.&lt;/p&gt;

&lt;h3 id=&quot;examples&quot;&gt;Examples&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Main.elm&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-elm&quot;&gt;update : Msg -&amp;gt; Model -&amp;gt; ( Model, Cmd Msg )
update msg model =
    case msg of
        SelectTab id -&amp;gt;
            ( { model | tabs = SelectList.select (\u -&amp;gt; u.id == id) model.tabs }, Cmd.none )
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;View.elm&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-elm&quot;&gt;view : Model -&amp;gt; Html Msg
view model =
    let
        befores =
            model.tabs
                |&amp;gt; SelectList.before
                |&amp;gt; List.map (tabView False)
&lt;/code&gt;&lt;/pre&gt;

&lt;h4 id=&quot;links&quot;&gt;Links&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://package.elm-lang.org/packages/rtfeldman/selectlist/latest&quot;&gt;rtfeldman/selectlist&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Zipper_(data_structure)&quot;&gt;Zipper Data Structure&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

        </description>
        <pubDate>Thu, 28 Sep 2017 18:00:00 +0000</pubDate>
        <link>https://elmseeds.thaterikperson.com/selectlist-zipper</link>
        <guid isPermaLink="true">https://elmseeds.thaterikperson.com/selectlist-zipper</guid>
        
        
      </item>
    
      <item>
        <title>GraphQL Fragments</title>
        <description>
          
          
            &lt;video width=&quot;100%&quot; height=&quot;100%&quot; controls poster=&quot;https://s3.amazonaws.com/elmseeds/ep-046/cover-art-960.png&quot;&gt;
              &lt;source src=&quot;https://s3.amazonaws.com/elmseeds/ep-046/ep-046.mp4&quot; type=&quot;video/mp4&quot; /&gt;
            &lt;/video&gt;
          
          &lt;p&gt;Fragments are reusable chunks of GraphQL queries that can help reduce code duplication across queries. We want to add support for them in our query builder so we can benefit from their reusability.&lt;/p&gt;

&lt;h3 id=&quot;examples&quot;&gt;Examples&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Main.elm&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-elm&quot;&gt;addressFragment : Fragment
addressFragment =
    fragment &quot;Address&quot; address


addressFields : Node -&amp;gt; Node
addressFields node =
    fields addressFragment node


user : Node -&amp;gt; Node
user user =
    user
        |&amp;gt; prop &quot;id&quot;
        |&amp;gt; prop &quot;email&quot;
        |&amp;gt; prop &quot;name&quot;
        |&amp;gt; node &quot;address&quot; [] addressFields
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;GraphQL.elm&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-elm&quot;&gt;type Fragment
    = Fragment String (Node -&amp;gt; Node)


fragment : String -&amp;gt; (Node -&amp;gt; Node) -&amp;gt; Fragment
fragment name func =
    Fragment name func


fields : Fragment -&amp;gt; Node -&amp;gt; Node
fields (Fragment typeName func) parent =
    let
        fieldsName =
            (String.toLower typeName) ++ &quot;Fields&quot;

        fragment_ =
            newNode (&quot;fragment &quot; ++ fieldsName ++ &quot; on &quot; ++ typeName) []
                |&amp;gt; func

        (Node node) =
            prop (&quot;...&quot; ++ fieldsName) parent
    in
        Node { node | fragments = fragment_ :: node.fragments }

&lt;/code&gt;&lt;/pre&gt;

&lt;h4 id=&quot;links&quot;&gt;Links&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://graphql.org/learn/queries/#fragments&quot;&gt;Fragments&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

        </description>
        <pubDate>Thu, 21 Sep 2017 18:00:00 +0000</pubDate>
        <link>https://elmseeds.thaterikperson.com/graphql-query-builder-fragments</link>
        <guid isPermaLink="true">https://elmseeds.thaterikperson.com/graphql-query-builder-fragments</guid>
        
        
      </item>
    
  </channel>
</rss>
