danielnarey/elm-toolkit/6.1.1

NOTE: this package is not compatible with Elm 0.19.1

Toolkit.List.Operators

Some experimental operators for working with lists

Appending lists and single elements

(|++) : appendable -> appendable -> appendable

Append the RHS to the end of the LHS; equivalent to ++, but left-associative with precedence set to 0 (same as |>)

("ba" |> String.reverse) ++ "c"


--> "abc"


"ba"
  |> String.reverse
  ++ "c"


--> ERROR


"ba"
  |> String.reverse
  |++ "c"


--> "abc"
(|::) : List a -> a -> List a

Append the item on the RHS to the end of the list on the LHS

[1]
  |:: 2


--> [1,2]


[1]
  |:: 2
  |:: 3


--> [1,2,3]
(:|++) : a -> List a -> List a

Wrap LHS in a list, then append RHS list to it; equivalent to ::, but left-associative with precedence set to 0 (same as |>)

("a" ++ "b")
  :: ["cd","ef"]


--> ["ab","cd","ef"]


"a" ++ "b"
  :: ["cd","ef"]


--> ERROR


"a" ++ "b"
 :|++ ["cd","ef"]


--> ["ab","cd","ef"]
(:|::) : a -> a -> List a

Wrap LHS in a list, then append the item on RHS to the list

1
 :|:: 2


--> [1,2]

Mapping functions

(.|>) : List a -> (a -> b) -> List b

Forward operator for List.map

[ 1
, 4
, 9
]
 .|> sqrt


--> [1,2,3]

Wrapping a single element and applying a list function

(:|>) : a -> (List a -> b) -> b

Wrap LHS in a list, then apply RHS function

1
 :|> List.head


--> Just 1