Skip to content

Instantly share code, notes, and snippets.

Rupert Smith rupertlssmith

  • The Sett Ltd.
  • Edinburgh, Scotland.
Block or report user

Report or block rupertlssmith

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View AsCustomType.elm
-- 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 =
View BasicSyntax.elm
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 / Tree.elm
Last active Jul 2, 2018
The 'tea-tree' data structure is a rose-tree implementation with some additional features that help when working with the Elm update cycle.
View Tree.elm
module Tree
exposing
( Tree
, Zipper
, Path
-- Tree operations
, singleton
, zipper
, map
-- Zipper operations
View Traits.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,
View ProgramCombinator.elm
module ProgramCombinator exposing (..)
import Html exposing (Html)
import Time exposing (Time, every, second)
-- Example
type alias Model =
@rupertlssmith
rupertlssmith / Channels.elm
Last active Jan 16, 2018
Experimenting with typed channels in Elm
View Channels.elm
module Channels exposing (..)
import Html exposing (Html)
import Time exposing (Time, every, second)
-- Example
type alias Model =
@rupertlssmith
rupertlssmith / GameState.elm
Last active Apr 1, 2020
Exploring State Machines with phantom types in Elm
View GameState.elm
module GameState
exposing
( Game(..)
, GameDefinition
, PlayState
, loading
, updateGameDefinition
, updatePlayState
, updateScore
, toReady
@rupertlssmith
rupertlssmith / StateModel.elm
Last active Jan 11, 2018
Experimenting with state machines in Elm
View StateModel.elm
module StateModel
exposing
( boolToMaybe
, (>&&>)
, (>||>)
, defaultTransition
, mapWhenCompose
)
import Maybe exposing (andThen)
You can’t perform that action at this time.