Skip to content

Instantly share code, notes, and snippets.

View TheSeamau5's full-sized avatar

Hassan Hayat TheSeamau5

  • Entrepreneur
  • Austin, TX
View GitHub Profile
import Signal exposing (Address)
import Html exposing (Html, div, button, text, span)
import Html.Events exposing (onClick)
type alias Init options state effect = options -> (state, List effect)
type alias Update action state effect = action -> state -> (state, List effect)
type alias View state view = state -> view
type alias Component options action state effect view =
import Signal exposing (Address)
import Html exposing (Html, div, button, span, text)
import Html.Events exposing (onClick)
type alias Component action state effect view
= Maybe action -> state -> (state, view, List effect)
type alias HtmlComponent action state effect
import Signal exposing (Address)
import Html exposing (Html, div, button, span, text)
import Html.Events exposing (onClick)
type alias Component action state effect view
= action
-> state
-> (state, List effect, view)
import Signal exposing (Address)
import Html exposing (Html, div, ul, li)
type alias Component action state effect view
= state
-> (action -> (state, List effect), view)
type alias HtmlComponent action state effect
= Component action state effect (Address action -> Html)
import Signal exposing (Address)
import Html exposing (Html, div, span, button, text)
import Html.Events exposing (onClick)
import Time
type alias Component action state effect view =
state -> (action -> (state, List effect), view)
type alias Function a b = a -> b
const : b -> Function a b
const b _ = b
compose : Function a b -> Function b c -> Function a c
compose =
(>>)
import Task exposing (Task)
type Never = Never Never
type Behavior a = Behavior (a -> Task Never (Behavior a))
contramap : (b -> a) -> Behavior a -> Behavior b
contramap f (Behavior g) =
Behavior (\b -> Task.map (contramap f) (g (f b)))
import Task exposing (Task)
type Never = Never Never
-------------
-- ADDRESS --
-------------
type alias Address a = a -> Task Never ()
-- An empty address that discards its input
type alias Reducer input state = input -> state -> state
dimapR : (a -> b) -> (b -> a) -> Reducer x a -> Reducer x b
dimapR f g reducer x b =
f (reducer x (g b))
contramap : (b -> a) -> Transducer a b r
contramap f reducer b =
reducer (f b)
import Task exposing (Task, succeed)
type Never = Never Never
type alias Address e = e -> Task Never ()
forwardTo : Address a -> (b -> a) -> Address b
forwardTo address f b =
address (f b)