Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/chadtech/tuple-infix
- Owner: Chadtech
- Created: 2017-11-05T15:41:11.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-04T03:43:40.000Z (about 7 years ago)
- Last Synced: 2024-11-06T04:40:57.764Z (about 2 months ago)
- Topics: elm
- Language: Elm
- Homepage: http://package.elm-lang.org/packages/Chadtech/tuple-infix/latest
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```