Skip to content

Instantly share code, notes, and snippets.

@knewter
knewter / Main.elm
Created August 9, 2016 21:16
Introduction to elm-mdl - 7
view : Model -> Html Msg
view model =
Material.Scheme.top <|
Layout.render Mdl
-- ...
@knewter
knewter / Main.elm
Created August 9, 2016 21:15
Introduction to elm-mdl - 6
type alias Model =
{ count : Int
, mdl :
Material.Model
-- Boilerplate: model store for any and all Mdl components you use.
, selectedTab : Int
}
model : Model
@knewter
knewter / Main.elm
Created August 9, 2016 21:15
Introduction to elm-mdl - 5
type Msg
-- ...
| SelectTab Int
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
-- ...
SelectTab num ->
@knewter
knewter / Main.elm
Created August 9, 2016 21:14
Introduction to elm-mdl - 4
view : Model -> Html Msg
view model =
Layout.render Mdl
model.mdl
[ Layout.fixedHeader
]
{ header = [ h1 [ style [ ( "padding", "2rem" ) ] ] [ text "Counter" ] ]
, drawer = []
, tabs = ( [ text "Milk", text "Oranges" ], [] )
, main = [ viewBody model ]
@knewter
knewter / Main.elm
Created August 9, 2016 21:13
Introduction to elm-mdl - 3
import Material.Layout as Layout
view : Model -> Html Msg
view model =
Layout.render Mdl
model.mdl
[ Layout.fixedHeader
]
{ header = [ h1 [ style [ ( "padding", "2rem" ) ] ] [ text "Counter" ] ]
, drawer = []
@knewter
knewter / Main.elm
Created August 9, 2016 21:11
Introduction to elm-mdl - 2
{- This file re-implements the Elm Counter example (1 counter) with elm-mdl
buttons. Use this as a starting point for using elm-mdl components in your own
app.
-}
module Main exposing (..)
import Html.App as App
import Html exposing (..)
@knewter
knewter / intro.sh
Created August 9, 2016 21:09
Introduction to elm-mdl - 1
mkdir mdl-playground
cd mdl-playground
elm package install -y debois/elm-mdl
vim Main.elm
@knewter
knewter / README.md
Created August 7, 2016 21:58
`assert_push` weirdness

If I run the tests with the code in bad.ex, I get the following:

warning: variable expected_song is unused
  test/channels/collusion_channel_test.exs:16

If I use good.ex, it works. (naming!)

This is a macro that's doing a match behind the scenes. If I am not careful to write a test that fails first, I'll think this works when it doesn't because it binds whatever I pass. For instance, if I change the test such that expected_song = %{}, which is not what the channel sends me, it will still pass without the hat obviously (though it does throw a warning)

@knewter
knewter / Main.elm
Last active July 18, 2016 16:01
Playing with typeclassy things, don't get mad
module Main exposing (..)
import Html.App as App
import Html exposing (..)
type Ord a
= Ord { less : a -> a -> Bool }
@knewter
knewter / Main.elm
Last active January 27, 2024 01:43 — forked from hoelzro/Main.elm
Bug in elm-lang/core `Dict.merge`?
module Main exposing (..)
import Html.App as App
import Html exposing (Html, text)
import Dict exposing (Dict)
type alias Model =
()