Skip to content

Instantly share code, notes, and snippets.

@hoelzro
Created June 16, 2016 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hoelzro/df60a864944ba6d14025bf204b81442f to your computer and use it in GitHub Desktop.
Save hoelzro/df60a864944ba6d14025bf204b81442f to your computer and use it in GitHub Desktop.
import Html.App as App
import Html exposing (Html, text)
import Dict exposing (Dict)
type alias Model = ()
type alias Msg = ()
existsInBoth : comparable -> (List a) -> (List a) -> Dict comparable (List a) -> Dict comparable (List a)
existsInBoth key leftValue rightValue dict =
Dict.insert key (leftValue ++ rightValue) dict
magicMerge : Dict comparable (List a) -> Dict comparable (List a) -> Dict comparable (List a)
magicMerge left right =
Dict.merge Dict.insert existsInBoth Dict.insert left right Dict.empty
init : (Model, Cmd Msg)
init = ((), Cmd.none)
update : Msg -> Model -> (Model, Cmd Msg)
update _ _ = ((), Cmd.none)
subscriptions : Model -> Sub Msg
subscriptions _ = Sub.none
view : Model -> Html Msg
view model = text <| toString <| magicMerge (Dict.empty |> Dict.insert "a" [1]) (Dict.empty |> Dict.insert "a" [2] |> Dict.insert "b" [3])
main : Program Never
main = App.program {
init = init,
update = update,
subscriptions = subscriptions,
view = view
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment