Skip to content

Instantly share code, notes, and snippets.

View cobalamin's full-sized avatar
👾

Simon Welker cobalamin

👾
View GitHub Profile
module FetchParallel exposing (..)
import Html exposing (Html, div, text, ul, li)
import Html.App exposing (program)
import Task
import Http
import Json.Decode as Json
import Json.Decode exposing ((:=))
import Dict exposing (Dict, fromList, toList)
import ZZZFetchJSON exposing (..)
module Temp exposing (..)
import Html exposing (..)
import Html.App as App
import Html.Events exposing (..)
import List
import Json.Decode as Json
join : List String -> String
join list = (List.foldr (++) "" list)
module Codec exposing (..)
import Json.Encode as Encode
type alias Listy =
{ a : List Int, b : Maybe String }
encodeListy : Listy -> Encode.Value
@cobalamin
cobalamin / ParseStopwatch.elm
Created August 5, 2016 15:06
Parsing a stopwatch-like time string format in Elm
module ParseStopwatch exposing (..)
import Parser exposing (..)
import Parser.Char exposing (..)
import Parser.Number exposing (digit)
import Char
import Time exposing (..)
twoDigitInt : Parser Int
@cobalamin
cobalamin / LetShadowing.elm
Last active August 3, 2016 14:34
Odd Elm compiler behaviour for shadowed mutual dependencies in `let` blocks
module LetShadowing exposing (..)
type alias TestModel = { dependency : String, id : Char }
borkMe : TestModel -> TestModel
borkMe model =
let
dep : String
dep =
Debug.log (toString model.id) model.dependency
module AudioControl exposing (..)
import Html exposing (Attribute, Html, audio, div, text, button)
import Html.Attributes exposing (class, controls, type', src, id, property)
import Html.App as App
import Html.Events exposing (on, onClick)
import Json.Decode as Json
import Json.Encode as Enc
import Debug
@cobalamin
cobalamin / BorkingElm.elm
Created August 1, 2016 16:55
Borking Elm
module BorkingElm exposing (..)
undefined : a
undefined = undefined
str : String
str = "hello" ++ undefined
num : Int
num = 1 + undefined
@cobalamin
cobalamin / DictSelect.elm
Last active July 28, 2016 20:23
Selecting a set of keys from an existing Dict to make a new one. Fails silently if key doesn't exist in old dict.
module DictSelect exposing (..)
import Dict exposing (Dict)
import Set
select : List comparable -> Dict comparable v -> Dict comparable v
select keys dict =
List.foldr (putIfIn dict) Dict.empty keys
@cobalamin
cobalamin / HaskellVsElm.md
Last active April 2, 2022 09:19
Elm (0.17) syntax and functionality differences for Haskell programmers
  • Types are declared with : and not ::, and the consing operator conversely is :: instead of :
  • No where clauses, only let/in
  • The standard style is different, check http://elm-lang.org/docs/style-guide for reference
  • Multiline strings are a thing with """
  • Haskell's data corresponds to type in Elm, and also, Haskell's type corresponds to Elm's type alias
  • ($) is (<|), but you don't use it all that much – Elm people like the flipped operator (|>) which lets you build something that reads like a pipeline
  • Related: Backticks will likely die soon in favour of functions that have an argument order that lends itself to pipelining with (|>)
  • Also, (.) is (<<), and a flipped version (>>) exists, but I don't see it used that much either
  • (&gt;&gt;=) is not an available operator and would not be polymorphic (no typeclasses, see below), and is instead commonly named SomeType.andThen – e.g. Maybe.andThen : Maybe a -&gt; (a -&gt; Maybe b) -&gt; Maybe b
@cobalamin
cobalamin / ChildAges.elm
Last active July 26, 2016 07:46 — forked from pfitz/ChildAges.elm
Add more beutifil
module ChildAges exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import Html.App
import String
import Array