Skip to content

Instantly share code, notes, and snippets.

Jason Dew jasondew

Block or report user

Report or block jasondew

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View alternative.elm
type Action
= Updated Response
| APIError Error
update : Action -> Model -> ( Model, Effects Action )
update action model =
case action of
Updated response -> -- do things
APIError error ->
let
View update.elm
update : Action -> Model -> ( Model, Effects Action )
update action model =
case action of
Updated result ->
case result of
Ok response -> -- do things
Err error -> -- handle error
View get.elm
requestUpdate : Effects Action
requestUpdate =
Http.get decoder url -- Task Error Response
|> Task.toResult -- Task never (Result Error Response)
|> Task.map Updated -- Task never Action
|> Effects.task -- Effects Action
View action.elm
type Action
= Updated (Result Error Response)
View basics.elm
type Response
= ...
type Action
= Updated (Maybe Response)
decoder : Decoder Response -- implementation elided
url : String -- ditto
update : Action -> Model -> ( Model, Effects Action )
View http.elm
get : Decoder value -> String -> Task Error value
@jasondew
jasondew / http.elm
Created Feb 1, 2016
HTTP error handling
View http.elm
update : Action -> Model -> ( Model, Effects Action )
update action model =
case action of
HandleResponse result ->
case result of
Ok movies ->
( { model | movies = movies }, Effects.none )
Err error ->
let
View keybase.md

Keybase proof

I hereby claim:

  • I am jasondew on github.
  • I am jasondew (https://keybase.io/jasondew) on keybase.
  • I have a public key whose fingerprint is D4FD 83C6 D891 37EC 3045 8745 3581 0583 7D91 64D9

To claim this, I am signing this object:

@jasondew
jasondew / JavaAccount.java
Created Jul 9, 2013
Java vs Ruby vs Scala
View JavaAccount.java
public class Account implements Serializable {
private String subdomain;
public String getSubdomain() {
return subdomain;
}
public void setSubdomain(String subdomain) {
this.subdomain = subdomain;
}
View das_download.rb
#! /usr/bin/env ruby
# usage:
# $ das_download.rb email password [download_directory]
require "mechanize"
class DasDownloader
attr_reader :agent, :email, :password
def initialize(email, password)
You can’t perform that action at this time.