Skip to content

Instantly share code, notes, and snippets.

View Chadtech's full-sized avatar

Chadtech Chadtech

  • SuperFocus.ai
  • Pennsylvania
View GitHub Profile
module Page.Register
exposing
( Model
, Msg(..)
, Problem(..)
, css
, init
, update
, view
)
update msg model =
case msg of
LoginClicked ->
attemptLogin model
FormSubmitted ->
model
|> validate
|> attemptLogin
type Msg
= DropdownItemClicked Int
type alias Model =
{ isDropped : Bool
, options : Array Thing
, selected : Int
}
import Json.Decoder as Decode
import Html.Events exposing (keyCode, on)
onEnter : msg -> Attribute msg
onEnter msg =
on "keydown" (keyCode |> Decode.andThen (enterDecoder msg))
enterDecoder : msg -> Int -> Decoder msg
enterDecoder msg keyCode =
case keyCode of
type Update
= SmallUpdate
| BigUpdate
| EnormousUpdate
validate : Appointment -> Appointment -> List Update
validate originalModel newModel =
[ differentCustomer
, differentTime

Someone in the Elm slack channel threw out this idea of naming Msg in the past tense, and not imperatively. I thought it was an interesting idea and I adopted the practice, just to try it out. I forgot who it was, I wish I could give them credit.

Anyway, the ramifications were more than I expected, and not simply the same Msg with different names. What I started doing is naming Msg as if they were saying "This happened". So where I would say "HandleUsernameField" I might instead say "UsernameFieldChanged" or instead of "Close" I would do "XClicked". What I didnt account for was that Msg and functionality dont map one to one. So for example, if you have a Msg named Navigate, its going to be the one Msg you use whenever you want to navigate. But if you are naming Msg as paste-tense descriptions, then several different things could happen that could cause a navigation. Since many things should cause a navigation, naming Msg in the past tense leads to lots of Msg which do the same thing.

update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
SetRoute route ->
case model.page of
Home homeModel ->
routeFromHome homeModel model route
Login loginModel ->
routeFromLogin loginModel model route

I just moved to Germany. I got a job here in Munich as an Elm developer. I have attended and hosted a lot of meet ups in my past, and I knew I was either going to join an existing Elm meet up or if necessary host one myself. My new company, Shore GmbH, turned out to be pretty excited by the idea of an Elm meet up. After finding that there was no active Elm meet up in Munich, Shore and I made a new meet up group called "Elm |> Munich" and hosted the first event on October 25th.

I wrote up an agenda for the event, which follows in line with some of my favorite meet up groups Ive been a part of: 0 introductions and preliminary socializing; 1 "open mic" show and tell; and 2 coding and socializing. Since it was our first event, we didnt really think we could rely on enough volunteer "open mic" talks, so we threw out an open invite through the meet up email, and recruited a few of our developers to give talks. The final line up was four talks. 0 A dev a Shore named Matheus who was going to talk about his experienc

Elm Meet Up Agenda Draft

  • 19:00 - Group Introduction Whoever is hosting tells everyone what the group is, and what the plan is for this meeting
  • 19:05 - Individual Introductions Everyone in the room introduces themselves, who they are, current projects etc
  • 19:15 - News, Announcements If the host knows of any big news shares, they share it, and also invites people to share whatever Elm happenings are going on in their world. General group-wide conversation
  • 19:25 - Show & Tell
@Chadtech
Chadtech / Idea.elm
Last active September 29, 2017 12:37
-- as it is
type alias Model =
-- ..
, staff : List Staff
, services : List Service
-- ..
, serviceName : String
, staffName : String
, serviceOrStaff : ServiceOrStaff
, servicesInDropDown : List Service