Skip to content

Instantly share code, notes, and snippets.

View pootsbook's full-sized avatar

Philip Poots pootsbook

  • ClubCollect
  • Alphen aan den Rijn, NL
View GitHub Profile
@pdamoc
pdamoc / Pong.elm
Last active October 16, 2016 20:07
Pong Example
-- See this document for more information on making Pong:
-- http://elm-lang.org/blog/pong
import Color exposing (..)
import Collage exposing (..)
import Element exposing (..)
import Keyboard
import Text
import Time exposing (..)
import Window exposing (Size)
import Html.App as App
import Html
import Html.App as App
import Html.Attributes as Attributes
import Html.Events as Events
import Json.Decode as Json
import String
main =
App.beginnerProgram

Type Safe JSON Decoding in Elm

The power of a Static Typed language can seem magical at first. But the goal here is to take a tiny peak behind that curtain.

Elm's implementation of JSON parsing is type safe and how it achieves that can seem like a mystery. Even though I got the code to work, it took me a while to fully understand how it works.

I'm writing it down here for 2 reasons. To help others gain a greater understanding of Types and so I don't forget what I learned.

Word of Caution

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@klaftertief
klaftertief / reactiveconf-2016-lightning-talk.md
Last active April 2, 2024 20:17
An API search engine in Elm for Elm, proposal for a Lightning Talk at ReactiveConf 2016

An API search engine in Elm for Elm

Elm is a statically typed functional language that compiles to JavaScript. It's well-known for its developer experience: the compiler provides nice error messages, the package system enforces semantic versioning for all published packages and makes sure every exposed value or type has some documentation and type annotations.

@chalmagean
chalmagean / onSelect.elm
Last active December 22, 2016 06:21
Elm onSelect decoder
-- Assuming we have a list of items in the model (type alias Model = { items : List Item }
-- where Item is a record like { id : Int, name : String }
-- this goes in the view and generates an html dropdown
select
[ onSelect ValueSelectedMsg ]
(List.map (\item -> option [ value (toString item.id) ] [ text item.name ]) model.items)
targetSelectedIndex : Json.Decoder Int
@avh4
avh4 / RichText.elm
Last active October 14, 2016 18:49 — forked from Janiczek/RichText.elm
-- the type aliases would be private
type RichText
= RichText (List Line)
type alias Line =
{ left : List (Attributes, String)
, center : List (Attributes, String)
, right : List (Attributes, String)

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@simonh1000
simonh1000 / DragTable.elm
Last active June 29, 2017 12:53
Draggable table
module DragTable exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Json.Decode as Json exposing (Decoder, Value)
import Dict exposing (Dict)
import List as L exposing (drop, take)
import Tuple
@jessejanderson
jessejanderson / the_abcs_of_otp.md
Last active March 13, 2024 11:23
The ABCs of OTP