Skip to content

Instantly share code, notes, and snippets.

View TheSeamau5's full-sized avatar

Hassan Hayat TheSeamau5

  • Entrepreneur
  • Austin, TX
View GitHub Profile

Type signatures for elm-html components (without effects)

First, consider the following type aliases

type alias Init options state = options -> state
-- type alias Init option state = Vector -> options -> state
-- alternative version if using inline styles

type alias Update action state = action -> state -> state
@TheSeamau5
TheSeamau5 / updateN.elm
Created July 20, 2015 16:26
UpdateN function
updateN : Int -> (a -> a) -> List a -> List a
updateN n f list =
List.indexedMap (\index value -> if index == n then f value else value) list
type alias Update action state = action -> state -> state
type alias View action state = Address action -> state -> Html
type alias Init options state = Vector -> options -> state
import Html exposing (Html)
import Signal exposing (Address)
type alias Vector =
{ x : Float , y : Float }
----------------------------------
type alias Init options state effect = options -> (state, effect)
type alias Update action state effect = action -> state -> (state, effect)
import Graphics.Element exposing (Element)
import Graphics.Collage exposing (..)
import Color
import Signal
import Time
-- Play with this value and hot swap the code
gravity = -9.8
--
import Graphics.Element exposing (Element)
import Graphics.Collage exposing (..)
import Color
import Signal
import Time
-- Play with this value and hot swap the code
gravity =
{ x = 1
import Html exposing (..)
import String
import List
import Color exposing (Color)
--
infixl 2 =>
(=>) = (,)
--
@TheSeamau5
TheSeamau5 / imagecaptureexample.html
Last active August 29, 2015 14:25
Image Capture example
<form>
<input id = "myInput" type="file" accept="image/*" capture="camera">
<img id ="myImage" src = "#"/>
</form>
import Html exposing (Html, Attribute, div, img, input)
import Html.Attributes exposing (style, src, width, height, type')
import Html.Events
import Json.Decode as Json exposing (Decoder, (:=))
import Signal exposing (Address)
import StartApp
import String
import Debug
@TheSeamau5
TheSeamau5 / infiniteprimes.elm
Created July 31, 2015 19:57
Infinite list of primes
import Html exposing (Html, Attribute, ul, li, text, div)
import Html.Attributes exposing (style)
import Html.Events
import Json.Decode as Json exposing (Decoder, (:=))
import Signal exposing (Address)
import StartApp
----------------------------------
initial : State Int
initial =