Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

Add an article about cool Elm shortcuts & helpers #18

Open
n1k0 opened this issue Feb 25, 2018 · 1 comment
Open

Add an article about cool Elm shortcuts & helpers #18

n1k0 opened this issue Feb 25, 2018 · 1 comment

Comments

@n1k0
Copy link
Contributor

n1k0 commented Feb 25, 2018

Out of my mind right now:

(=>)

From elm-example-spa:

(=>) : a -> b -> ( a, b )
(=>) =
    (,)


{-| infixl 0 means the (=>) operator has the same precedence as (<|) and (|>),
meaning you can use it at the end of a pipeline and have the precedence work out.
-}
infixl 0 =>

So that you can write tuples like this:

    case msg of
        DismissErrors -> 
            { model | errors = [] } => Cmd.none

(?)

From take-home:

(?) : Maybe a -> a -> a
(?) mx x =
    Maybe.withDefault x mx

So you can write:

key = Dict.get myConfig.accessKey env ? ""

Let's collect other nice things here.

@vjousse
Copy link
Contributor

vjousse commented Feb 25, 2018

what about the famous ! for the model/cmd combo? I was so puzzled at the beginning by this syntax…

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants