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]
A summary of the Elm architectures/compilation/installation/usage matrix state of affairs.
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); | |
} |
{- 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 |
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:
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).
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) |
If you’ve ever wanted to analyze your own health data, here’s how.
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 |
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 😉
There's a lot of type terminology and jargon going around when discussing types in Elm. This glossary attempts to list some of the most common type terms along with synonyms, terms from other language communities, examples, and links to more detailed articles on each topic.