Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/chadtech/tuple-infix

Infix functions to tuple in Elm
https://github.com/chadtech/tuple-infix

elm

Last synced: 1 day ago
JSON representation

Infix functions to tuple in Elm

Awesome Lists containing this project

README

        

# Tuple-Infix (&, :=)

In nearly all of my Elm projects, I use these two infix functions: `&` and `:=`. They both tuple, but I use them differently. `&` is used just to tuple two random things, like at the end of an update function.

```elm
Noop ->
model & Cmd.none
```
`:=` I use whenever the tuple is being used to "define" the left value as the right, as I do in inline styles and json encoding (`"left" = "16px"` or `"type" := Encode.string type_`)

```elm
div
[ style [ "left" := "40px" ] ]
[]

packJsMsg : String -> Encode.Value -> Encode.Value
packJsMsg type_ payload =
[ "type" := Encode.string type_
, "payload" := payload
]
|> Encode.object
```