mbr / elm-extras / Extras.Core

General convenience functions.

byKey : (a -> b) -> b -> a -> Basics.Bool

Create a predicate that matches on a specific extracted value.

> let alice = { id = 1, name = "Alice" }
|     bob = { id = 2, name = "Bob" }
|     users =
| in List.filter (byKey .id 2) users
[{ id = 2, name = "Bob" }]

flip : (a -> b -> c) -> b -> a -> c

Change the order of the arguments of a two argument function.

> flip (++) "Hello" "World"
"WorldHello" : String

unless : Basics.Bool -> a -> a -> a

Negated, functional if-then-else.

Checks a condition and returns the respective value.

Allows writing more natural conditional atttributes, elements, etc:

div [] [ unless isLoggedIn (text "not logged in") (a [] [ text "logout" ]) ]