Created
June 16, 2016 20:47
-
-
Save hoelzro/df60a864944ba6d14025bf204b81442f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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