Skip to content

Instantly share code, notes, and snippets.

View rupertlssmith's full-sized avatar

Rupert Smith rupertlssmith

  • The Sett Ltd.
  • Edinburgh, Scotland.
View GitHub Profile
@rupertlssmith
rupertlssmith / StateModel.elm
Last active January 11, 2018 16:19
Experimenting with state machines in Elm
module StateModel
exposing
( boolToMaybe
, (>&&>)
, (>||>)
, defaultTransition
, mapWhenCompose
)
import Maybe exposing (andThen)
@rupertlssmith
rupertlssmith / GameState.elm
Last active October 9, 2024 09:35
Exploring State Machines with phantom types in Elm
module GameState
exposing
( Game(..)
, GameDefinition
, PlayState
, loading
, updateGameDefinition
, updatePlayState
, updateScore
, toReady
@rupertlssmith
rupertlssmith / Channels.elm
Last active January 16, 2018 11:48
Experimenting with typed channels in Elm
module Channels exposing (..)
import Html exposing (Html)
import Time exposing (Time, every, second)
-- Example
type alias Model =
@rupertlssmith
rupertlssmith / ProgramCombinator.elm
Created January 19, 2018 15:13
Program Combinator
module ProgramCombinator exposing (..)
import Html exposing (Html)
import Time exposing (Time, every, second)
-- Example
type alias Model =
@rupertlssmith
rupertlssmith / Traits.elm
Created June 12, 2018 10:36
Traits in Elm
module Traits exposing (..)
type GameState
= State
{-| FireTrait defines how the game state is updated for any kind of shooting
event.
's' is the state implementation parameter,
@rupertlssmith
rupertlssmith / Tree.elm
Last active July 2, 2018 11:12
The 'tea-tree' data structure is a rose-tree implementation with some additional features that help when working with the Elm update cycle.
module Tree
exposing
( Tree
, Zipper
, Path
-- Tree operations
, singleton
, zipper
, map
-- Zipper operations
@rupertlssmith
rupertlssmith / BasicSyntax.elm
Last active December 4, 2018 21:16
Elm Syntax
module BasicSyntax exposing (..)
fact : Int -> Int
fact n =
if n == 0 then
1
else
n * fact (n - 1)
map : (a -> b) -> List a -> List b
@rupertlssmith
rupertlssmith / AsCustomType.elm
Last active October 30, 2019 16:20
Elm Enums
-- This way gives you a custom type, which can be used to branch on in code with case of.
type Pet
= Cat
| Dog
| Snake
| Spider
petEnum =
@rupertlssmith
rupertlssmith / LocalStoragePort.elm
Last active January 31, 2022 15:41
Local storage using Elm port.
port module Ports.LocalStoragePort exposing (clear, getItem, listKeys, response, setItem)
import LocalStorage exposing (ClearPort, GetItemPort, ListKeysPort, ResponsePort, SetItemPort)
port getItem : GetItemPort msg
port setItem : SetItemPort msg
@rupertlssmith
rupertlssmith / ElmPackageServer.md
Last active February 28, 2024 17:38
Elm Package Server

Eco - An Alternate Elm Package Server

Eco is an alternative package management system for Elm. The name can stand for "Elm Compiler Offline".

The idea is to have a more configurable package management system for Elm, that allows for sharing private packages.

The main use case for this is intended to be within organizations, where a software developer or team can publish a private package that applications, or other private packages, in that organization can consume. This will support transitive dependency resolution in the same way that public Elm packages do.

The main repository and source of truth will be the existing package.elm-lang.org site.