Skip to content

Instantly share code, notes, and snippets.

View absynce's full-sized avatar

Jared M. Smith absynce

View GitHub Profile
@JoelQ
JoelQ / elm-generic-types-exercises.md
Last active June 14, 2022 21:22
Short exercises to learn how generic types and type variables work in Elm.

Generic Elm types exercises

A series of exercises to get a feel for how generic types and type variables work in Elm. For each of these, you are given some code that is not compiling. Your task is to get it compiling. You can change the body of the function but not the signature. No cheating with Debug.todo or infinite recursions either 😉

module ID exposing (ID(..), decodeFromString, decoder, encode, encodeAsString, fromInt, toInt, toString)
import Json.Decode as Decode exposing (Decoder)
import Json.Encode as Encode exposing (Value)
{-| This type ensures you get a type error if you for example accidentally pass a UserId in place of a CompanyId
-}
type ID phantom
= ID Int

Parsing Apple Health data

If you’ve ever wanted to analyze your own health data, here’s how.

Exporting as XML

  1. Open the Health app.
  2. Tap on your profile in the top right.
  3. Tap Export All Health Data.
  4. Share the archive with yourself (e.g. via AirDrop, Files, Mail, etc.).
@jfmengels
jfmengels / NoMissingTypeConstructor.elm
Last active September 27, 2021 17:55
NoMissingTypeConstructor elm-review rule
module NoMissingTypeConstructor exposing (rule)
import Dict exposing (Dict)
import Elm.Syntax.Declaration as Declaration exposing (Declaration)
import Elm.Syntax.Expression as Expression exposing (Expression)
import Elm.Syntax.ModuleName exposing (ModuleName)
import Elm.Syntax.Node as Node exposing (Node)
import Elm.Syntax.Type exposing (Type)
import Elm.Syntax.TypeAnnotation as TypeAnnotation exposing (TypeAnnotation)
import Review.ModuleNameLookupTable as ModuleNameLookupTable exposing (ModuleNameLookupTable)
@supermario
supermario / readme.md
Last active March 21, 2022 15:07
Elm code splitting and the impact of dead-code-elimination

The question of code-splitting in Elm comes up fairly routinely.

The apparent low-hanging-fruit of code-splitting with Elm's pure/immutable philosophy has led me to explore this a few times with my compiler work on Lamdera.

Here are some of the challenges I've found:

The impact of Elm's current live-code-inclusion (LCI?)

It's a little trickier than it looks because Elm's DCE is actually not DCE (dead code elimination) at all, it's LCI (live code inclusion).

{- A sketch for a potential responsive API for elm-ui
First, the API. Following will be some example code!
-}
-- defining a set of global window-width breakpoints
breakpoints : label -> List (Breakpoint label) -> Breakpoints label
@wolfadex
wolfadex / elm-portal.js
Last active April 29, 2025 16:19
A Portal web component for Elm
window.customElements.define("elm-portal", class extends HTMLElement {
// Base custom element stuff
constructor() {
super();
this._targetNode = document.createElement('div');
}
connectedCallback() {
document.querySelector(this.getAttribute("data-target-selector")).appendChild(this._targetNode);
}
@dwayne
dwayne / custom-properties.md
Last active August 7, 2023 08:34
Elm Odds and Ends

Custom Properties in Elm

Html.Attributes.style does not support setting custom properties. For e.g. the following won't work:

style "--alert-text-color" "#123456"

re: [Asking for support][support]