list-extra
list-extra copied to clipboard
Proposal for push
trafficstars
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.
I would personally prefer |> \elem -> elem :: allMyElems here. Just my two cents.
I dont think its really that useful. In these cases I do..
doSomethingWithElems : a -> List a -> List a
doSomethingWithElems myElem =
(::) (dosomethingWithTheElem myElem)