elm-community / list-extra

Convenience functions for working with List.
http://package.elm-lang.org/packages/elm-community/list-extra/latest
MIT License
135 stars 58 forks source link

Proposal for push #104

Open ghivert opened 6 years ago

ghivert commented 6 years ago

Hi.

I'm often using something like

pushIn : List a -> a -> List a
pushIn list elem =
  elem :: list

to use it into pipelines

doSomethingWithElems : a -> List a -> List a
doSomethingWithElems myElem allMyElems =
  myElem
    |> doSomethingWithTheElem
    |> pushIn allMyElems

What do you think about it? It's the exact reverse of (::), but since flip is gone, I think it is worthwhile.

pzp1997 commented 6 years ago

I would personally prefer |> \elem -> elem :: allMyElems here. Just my two cents.

Chadtech commented 6 years ago

I dont think its really that useful. In these cases I do..

doSomethingWithElems : a -> List a -> List a
doSomethingWithElems myElem =
    (::) (dosomethingWithTheElem myElem)